Index: /branches/SHM-5.0-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-5.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 595)
+++ /branches/SHM-5.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 596)
@@ -977,5 +977,12 @@
       g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC;
 #endif
-      vps->setLayerIdIncludedFlag(true, setId, layerId);
+      if( layerId <= setId )
+      {
+        vps->setLayerIdIncludedFlag(true, setId, layerId);
+      }
+      else
+      {
+        vps->setLayerIdIncludedFlag(false, setId, layerId);
+      }
     }
   }
Index: /branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 595)
+++ /branches/SHM-5.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 596)
@@ -2189,5 +2189,5 @@
   // For other layers
   Int i, m, n;
-  for( i = 1; i <= m_numLayerSets - 1; i++ )
+  for( i = 1; i < m_numLayerSets; i++ )
   {
     n = 0;
@@ -2196,6 +2196,5 @@
       if( m_layerIdIncludedFlag[i][m] )
       {
-        m_layerSetLayerIdList[i][n] = m;
-        n++;
+        m_layerSetLayerIdList[i][n++] = m;
       }
     }
