diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp
index f2def0a075aba83e13645740ad5cf9176e935e83..a6d215f237b34c24eaacdca639822fa4ca66450c 100644
--- a/source/Lib/CommonLib/Slice.cpp
+++ b/source/Lib/CommonLib/Slice.cpp
@@ -2515,10 +2515,10 @@ bool ParameterSetManager::activatePPS(int ppsId, bool isIRAP)
 
 bool ParameterSetManager::activateAPS(int apsId, int apsType)
 {
-  APS *aps = m_apsMap.getPS((apsId << NUM_APS_TYPE_LEN) + apsType);
+  APS *aps = m_apsMap.getPS(apsId + (MAX_NUM_APS * apsType));
   if (aps)
   {
-    m_apsMap.setActive((apsId << NUM_APS_TYPE_LEN) + apsType);
+    m_apsMap.setActive(apsId + (MAX_NUM_APS * apsType));
     return true;
   }
   else
diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h
index 560379242718122c6617966223a826569ea8d177..5822eed98a044aee1537d636ad713bc2fda1ec35 100644
--- a/source/Lib/CommonLib/Slice.h
+++ b/source/Lib/CommonLib/Slice.h
@@ -2510,10 +2510,10 @@ public:
   bool           activatePPS(int ppsId, bool isIRAP);
   APS**          getAPSs() { return &m_apss[0]; }
   ParameterSetMap<APS>* getApsMap() { return &m_apsMap; }
-  void           storeAPS(APS *aps, const std::vector<uint8_t> &naluData)    { m_apsMap.storePS((aps->getAPSId() << NUM_APS_TYPE_LEN) + aps->getAPSType(), aps, &naluData); };
-  APS*           getAPS(int apsId, int apsType)                              { return m_apsMap.getPS((apsId << NUM_APS_TYPE_LEN) + apsType); };
-  bool           getAPSChangedFlag(int apsId, int apsType) const             { return m_apsMap.getChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); }
-  void           clearAPSChangedFlag(int apsId, int apsType)                 { m_apsMap.clearChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); }
+  void           storeAPS(APS *aps, const std::vector<uint8_t> &naluData)    { m_apsMap.storePS(aps->getAPSId() + (MAX_NUM_APS * aps->getAPSType()), aps, &naluData); };
+  APS*           getAPS(int apsId, int apsType)                              { return m_apsMap.getPS(apsId + (MAX_NUM_APS * apsType)); };
+  bool           getAPSChangedFlag(int apsId, int apsType) const             { return m_apsMap.getChangedFlag(apsId + (MAX_NUM_APS * apsType)); }
+  void           clearAPSChangedFlag(int apsId, int apsType)                 { m_apsMap.clearChangedFlag(apsId + ( MAX_NUM_APS * apsType)); }
   APS*           getFirstAPS()                                               { return m_apsMap.getFirstPS(); };
   bool           activateAPS(int apsId, int apsType);
   const SPS*     getActiveSPS()const                                         { return m_spsMap.getPS(m_activeSPSId); };
diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp
index 3a4ce3f8d1305f607f5a54d23614d9e7de1a1adb..8d39c2367cf07054b3eb9eb7b4a32515f6667502 100644
--- a/source/Lib/DecoderLib/DecLib.cpp
+++ b/source/Lib/DecoderLib/DecLib.cpp
@@ -813,11 +813,33 @@ void activateAPS(Slice* pSlice, ParameterSetManager& parameterSetManager, APS**
 #endif
 {
   //luma APSs
-  for (int i = 0; i < pSlice->getTileGroupApsIdLuma().size(); i++)
+  if (pSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y))
   {
-    int apsId = pSlice->getTileGroupApsIdLuma()[i];
-    APS* aps = parameterSetManager.getAPS(apsId, ALF_APS);
+    for (int i = 0; i < pSlice->getTileGroupApsIdLuma().size(); i++)
+    {
+      int apsId = pSlice->getTileGroupApsIdLuma()[i];
+      APS* aps = parameterSetManager.getAPS(apsId, ALF_APS);
+
+      if (aps)
+      {
+        apss[apsId] = aps;
+        if (false == parameterSetManager.activateAPS(apsId, ALF_APS))
+        {
+          THROW("APS activation failed!");
+        }
 
+#if JVET_O0245_VPS_DPS_APS
+        CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" );
+        //ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it.
+#endif
+      }
+    }
+  }
+  if (pSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cb)||pSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cr) )
+  {
+    //chroma APS
+    int apsId = pSlice->getTileGroupApsIdChroma();
+    APS* aps = parameterSetManager.getAPS(apsId, ALF_APS);
     if (aps)
     {
       apss[apsId] = aps;
@@ -833,23 +855,6 @@ void activateAPS(Slice* pSlice, ParameterSetManager& parameterSetManager, APS**
     }
   }
 
-  //chroma APS
-  int apsId = pSlice->getTileGroupApsIdChroma();
-  APS* aps = parameterSetManager.getAPS(apsId, ALF_APS);
-  if (aps)
-  {
-    apss[apsId] = aps;
-    if (false == parameterSetManager.activateAPS(apsId, ALF_APS))
-    {
-      THROW("APS activation failed!");
-    }
-
-#if JVET_O0245_VPS_DPS_APS
-    CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" );
-    //ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it.
-#endif
-  }
-
   if (pSlice->getLmcsEnabledFlag() && lmcsAPS == nullptr)
   {
     lmcsAPS = parameterSetManager.getAPS(pSlice->getLmcsAPSId(), LMCS_APS);
@@ -1863,9 +1868,8 @@ void DecLib::xDecodeSPS( InputNALUnit& nalu )
 #endif
 
   m_HLSReader.parseSPS( sps );
-  m_parameterSetManager.storeSPS( sps, nalu.getBitstream().getFifo() );
-
   DTRACE( g_trace_ctx, D_QP_PER_CTU, "CTU Size: %dx%d", sps->getMaxCUWidth(), sps->getMaxCUHeight() );
+  m_parameterSetManager.storeSPS( sps, nalu.getBitstream().getFifo() );
 }
 
 void DecLib::xDecodePPS( InputNALUnit& nalu )