Index: branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_2view.cfg
===================================================================
--- branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_2view.cfg	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_2view.cfg	(revision 495)
@@ -30,5 +30,5 @@
 OutputLayerSetIdx             : 1            # Indices of layer sets used as additional output layer sets
 LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-ProfileLevelTierIdx           : 0 0          # Indices to profile level tier (TBD)
+ProfileLevelTierIdx           : 0 0 0        # Indices to profile level tier (TBD) per output layer set
 
 #======== VPS / Dependencies ================
Index: branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg
===================================================================
--- branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg	(revision 495)
@@ -43,5 +43,5 @@
 LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
 LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
-ProfileLevelTierIdx           : 0 0 0 0 0 0  # Indices to profile level tier (TBD)
+ProfileLevelTierIdx           : 0 0 0 0 0 0 0 0 # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
Index: branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view.cfg
===================================================================
--- branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view.cfg	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view.cfg	(revision 495)
@@ -35,5 +35,5 @@
 LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
 LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
-ProfileLevelTierIdx           : 0 0 0 0      # Indices to profile level tier (TBD)
+ProfileLevelTierIdx           : 0 0 0 0 0 0   # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
Index: branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_2view.cfg
===================================================================
--- branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_2view.cfg	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_2view.cfg	(revision 495)
@@ -30,5 +30,5 @@
 OutputLayerSetIdx             : 1            # Indices of layer sets used as additional output layer sets
 LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
-ProfileLevelTierIdx           : 0            # Indices to profile level tier (TBD)
+ProfileLevelTierIdx           : 0 0 0        # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
Index: branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_3view.cfg
===================================================================
--- branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_3view.cfg	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_3view.cfg	(revision 495)
@@ -35,5 +35,5 @@
 LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds in vps of additional output layers
 LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds in vps of additional output layers
-ProfileLevelTierIdx           : 0 0 0 0      # Indices to profile level tier (TBD)
+ProfileLevelTierIdx           : 0 0 0 0 0 0  # Indices to profile level tier (TBD)
 
 #======== VPS / Dependencies ================
Index: branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 495)
@@ -228,5 +228,8 @@
     in>>entry.m_interViewRefPosL[1][i];
   }
-  in>>entry.m_collocatedRefLayerIdx; 
+  if (entry.m_numActiveRefLayerPics > 0 )
+  {
+    in>>entry.m_collocatedRefLayerIdx; 
+  }
 #endif
   return in;
@@ -1375,9 +1378,9 @@
 
   // Output layer sets
-  xConfirmPara( m_outputLayerSetIdx.size() < 0 || m_outputLayerSetIdx.size() > 1024, "The number of output layer set indices must be less than 1025") ;
+  xConfirmPara( m_outputLayerSetIdx.size() < 0 || m_outputLayerSetIdx.size() > 1024, "The number of output layer set indices must be less than 1025.") ;
   for (Int lsIdx = 0; lsIdx < m_outputLayerSetIdx.size(); lsIdx++)
   {   
     Int refLayerSetIdx = m_outputLayerSetIdx[ lsIdx ]; 
-    xConfirmPara(  refLayerSetIdx < 0 || refLayerSetIdx >= m_vpsNumLayerSets, "Output layer set idx must be greater or equal to 0 and less than the VpsNumLayerSets" );
+    xConfirmPara(  refLayerSetIdx < 0 || refLayerSetIdx >= m_vpsNumLayerSets, "Output layer set idx must be greater or equal to 0 and less than the VpsNumLayerSets." );
 
     for (Int i = 0; i < m_layerIdsInAddOutputLayerSet[ lsIdx ].size(); i++)
@@ -1390,7 +1393,7 @@
           isAlsoInLayerSet = true; 
           break; 
-        }
-        xConfirmPara( !isAlsoInLayerSet, "All output layers must of a output layer set be included in corresponding layer set");
-      }
+        }        
+      }
+      xConfirmPara( !isAlsoInLayerSet, "All output layers of a output layer set be included in corresponding layer set.");
     }
   }
@@ -1401,5 +1404,5 @@
   {
     xConfirmPara( (i == 0)  && m_directRefLayers[0].size() != 0, "Layer 0 shall not have reference layers." ); 
-    xConfirmPara( m_directRefLayers[i].size() == m_dependencyTypes[ i ].size() != 0, "Each reference layer shall have a reference type" ); 
+    xConfirmPara( m_directRefLayers[i].size() != m_dependencyTypes[ i ].size(), "Each reference layer shall have a reference type." ); 
     for (Int j = 0; j < m_directRefLayers[i].size(); j++)
     {
@@ -1573,24 +1576,25 @@
   if( m_numberOfLayers > 1 )
   {
-    for( Int k = 1; k < m_numberOfLayers; k++ )
+    for( Int layer = 1; layer < m_numberOfLayers; layer++ )
     {
       for( Int i = 0; i < MAX_GOP+1; i++ )
       {
-        for( Int j = 0; j < m_GOPListMvc[k][i].m_numActiveRefLayerPics; j++ )
+        GOPEntry gopEntry = m_GOPListMvc[layer][i];  
+        for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
         {
-          Int ilPredLayerIdc = m_directRefLayers[k][m_GOPListMvc[k][i].m_interLayerPredLayerIdc[j]];
-          if( ilPredLayerIdc < 0 || ilPredLayerIdc >= m_directRefLayers[k].size() )
+          Int ilPredLayerIdc = gopEntry.m_interLayerPredLayerIdc[j];
+          if( ilPredLayerIdc < 0 || ilPredLayerIdc >= m_directRefLayers[layer].size() )
           {
-            printf( "\nError: inter-layer ref idc %d is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interLayerPredLayerIdc[j], i, k );
+            printf( "\nError: inter-layer ref idc %d is not available for Frame%d_l%d\n", gopEntry.m_interLayerPredLayerIdc[j], i, layer );
             bErrorIvpEnhV = true;
           }
-          if( m_GOPListMvc[k][i].m_interViewRefPosL[0][j] < -1 || m_GOPListMvc[k][i].m_interViewRefPosL[0][j] > m_GOPListMvc[k][i].m_numRefPicsActive )
+          if( gopEntry.m_interViewRefPosL[0][j] < -1 || gopEntry.m_interViewRefPosL[0][j] > gopEntry.m_numRefPicsActive )
           {
-            printf( "\nError: inter-layer ref pos %d on L0 is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interViewRefPosL[0][j], i, k );
+            printf( "\nError: inter-layer ref pos %d on L0 is not available for Frame%d_l%d\n", gopEntry.m_interViewRefPosL[0][j], i, layer );
             bErrorIvpEnhV = true;
           }
-          if( m_GOPListMvc[k][i].m_interViewRefPosL[1][j] < -1  || m_GOPListMvc[k][i].m_interViewRefPosL[1][j] > m_GOPListMvc[k][i].m_numRefPicsActive )
+          if( gopEntry.m_interViewRefPosL[1][j] < -1  || gopEntry.m_interViewRefPosL[1][j] > gopEntry.m_numRefPicsActive )
           {
-            printf( "\nError: inter-layer ref pos %d on L1 is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interViewRefPosL[1][j], i, k );
+            printf( "\nError: inter-layer ref pos %d on L1 is not available for Frame%d_l%d\n", gopEntry.m_interViewRefPosL[1][j], i, layer );
             bErrorIvpEnhV = true;
           }
@@ -1598,63 +1602,63 @@
         if( i == MAX_GOP ) // inter-view refs at I pic position in base view
         {
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType != 'B' && m_GOPListMvc[k][MAX_GOP].m_sliceType != 'P' && m_GOPListMvc[k][MAX_GOP].m_sliceType != 'I' )
+          if( gopEntry.m_sliceType != 'B' && gopEntry.m_sliceType != 'P' && gopEntry.m_sliceType != 'I' )
           {
-            printf( "\nError: slice type of FrameI_l%d must be equal to B or P or I\n", k );
+            printf( "\nError: slice type of FrameI_l%d must be equal to B or P or I\n", layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_POC != 0 )
+          if( gopEntry.m_POC != 0 )
           {
-            printf( "\nError: POC %d not possible for FrameI_l%d, must be 0\n", m_GOPListMvc[k][MAX_GOP].m_POC, k );
+            printf( "\nError: POC %d not possible for FrameI_l%d, must be 0\n", gopEntry.m_POC, layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_temporalId != 0 )
+          if( gopEntry.m_temporalId != 0 )
           {
-            printf( "\nWarning: Temporal id of FrameI_l%d must be 0 (cp. I-frame in base layer)\n", k );
-            m_GOPListMvc[k][MAX_GOP].m_temporalId = 0;
+            printf( "\nWarning: Temporal id of FrameI_l%d must be 0 (cp. I-frame in base layer)\n", layer );
+            gopEntry.m_temporalId = 0;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_numRefPics != 0 )
+          if( gopEntry.m_numRefPics != 0 )
           {
-            printf( "\nWarning: temporal references not possible for FrameI_l%d\n", k );
-            for( Int j = 0; j < m_GOPListMvc[k][MAX_GOP].m_numRefPics; j++ )
+            printf( "\nWarning: temporal references not possible for FrameI_l%d\n", layer );
+            for( Int j = 0; j < m_GOPListMvc[layer][MAX_GOP].m_numRefPics; j++ )
             {
-              m_GOPListMvc[k][MAX_GOP].m_referencePics[j] = 0;
+              gopEntry.m_referencePics[j] = 0;
             }
-            m_GOPListMvc[k][MAX_GOP].m_numRefPics = 0;
+            gopEntry.m_numRefPics = 0;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_interRPSPrediction )
+          if( gopEntry.m_interRPSPrediction )
           {
-            printf( "\nError: inter RPS prediction not possible for FrameI_l%d, must be 0\n", k );
+            printf( "\nError: inter RPS prediction not possible for FrameI_l%d, must be 0\n", layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'I' && m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics != 0 )
+          if( gopEntry.m_sliceType == 'I' && gopEntry.m_numActiveRefLayerPics != 0 )
           {
-            printf( "\nError: inter-layer prediction not possible for FrameI_l%d with slice type I, #IL_ref_pics must be 0\n", k );
+            printf( "\nError: inter-layer prediction not possible for FrameI_l%d with slice type I, #IL_ref_pics must be 0\n", layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive > m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics )
+          if( gopEntry.m_numRefPicsActive > gopEntry.m_numActiveRefLayerPics )
           {
-            m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive = m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics;
+            gopEntry.m_numRefPicsActive = gopEntry.m_numActiveRefLayerPics;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'P' )
+          if( gopEntry.m_sliceType == 'P' )
           {
-            if( m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics < 1 )
+            if( gopEntry.m_numActiveRefLayerPics < 1 )
             {
-              printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type P\n", k );
+              printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type P\n", layer );
               bErrorIvpEnhV = true;
             }
             else
             {
-              for( Int j = 0; j < m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics; j++ )
+              for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
               {
-                if( m_GOPListMvc[k][MAX_GOP].m_interViewRefPosL[1][j] != -1 )
+                if( gopEntry.m_interViewRefPosL[1][j] != -1 )
                 {
-                  printf( "\nError: inter-layer ref pos %d on L1 not possible for FrameI_l%d with slice type P\n", m_GOPListMvc[k][MAX_GOP].m_interViewRefPosL[1][j], k );
+                  printf( "\nError: inter-layer ref pos %d on L1 not possible for FrameI_l%d with slice type P\n", gopEntry.m_interViewRefPosL[1][j], layer );
                   bErrorIvpEnhV = true;
                 }
@@ -1663,7 +1667,7 @@
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'B' && m_GOPListMvc[k][MAX_GOP].m_numActiveRefLayerPics < 1 )
+          if( gopEntry.m_sliceType == 'B' && gopEntry.m_numActiveRefLayerPics < 1 )
           {
-            printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type B\n", k );
+            printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type B\n", layer );
             bErrorIvpEnhV = true;
           }
Index: branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 495)
@@ -90,6 +90,5 @@
   Int                    m_vpsNumLayerSets;                   ///< Number of layer sets
   std::vector< std::vector<Int> > m_layerIdsInSets;           ///< LayerIds in vps of layer set 
-  Bool                   m_defaultOneTargetOutputLayerFlag;   ///< Output highest layer of layer sets by default
-  Int                    numAddOuputLayerSets;                ///< Number of additional output layer sets
+  Bool                   m_defaultOneTargetOutputLayerFlag;   ///< Output highest layer of layer sets by default  
   std::vector<Int>       m_outputLayerSetIdx;                 ///< Indices of layer sets used as additional output layer sets  
   std::vector< std::vector<Int> > m_layerIdsInAddOutputLayerSet; ///< LayerIds in vps of additional output layers
@@ -97,6 +96,6 @@
   
   // Dependencies
-  std::vector<std::vector<Int>> m_directRefLayers;             ///< LayerIds of direct reference layers
-  std::vector<std::vector<Int>> m_dependencyTypes;             ///< Dependency types of direct reference layers
+  std::vector< std::vector<Int> > m_directRefLayers;          ///< LayerIds of direct reference layers
+  std::vector< std::vector<Int> > m_dependencyTypes;          ///< Dependency types of direct reference layers
 #endif
   Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
Index: branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 495)
@@ -119,4 +119,5 @@
   xSetDimensionIdAndLength ( vps );
   xSetDependencies( vps );
+  xSetProfileTierLevel     ( vps ); 
   xSetLayerSets            ( vps ); 
 #if H_3D
@@ -993,11 +994,11 @@
     {
       vps.setDirectDependencyFlag( depLayer, refLayer, false); 
-      vps.setDirectDependencyType( depLayer, refLayer,    0 ); 
+      vps.setDirectDependencyType( depLayer, refLayer,    -1 ); 
     }
   } 
   for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ )
   {
-    Int numRefLayers = m_directRefLayers[depLayer].size(); 
-    assert(  numRefLayers == m_dependencyTypes[depLayer].size() ); 
+    Int numRefLayers = (Int) m_directRefLayers[depLayer].size(); 
+    assert(  numRefLayers == (Int) m_dependencyTypes[depLayer].size() ); 
     for( Int i = 0; i < numRefLayers; i++ )
     {
@@ -1012,15 +1013,16 @@
   {  
     Int maxTid = -1; 
-    for ( Int currLayerIdInVps = 1; currLayerIdInVps < m_numberOfLayers; currLayerIdInVps++)
+    for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++)
     {
       for( Int i = 0; i < getGOPSize(); i++ ) 
       {        
-        GOPEntry ge =  m_GOPListMvc[currLayerIdInVps][i];
+        GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][i];
+        GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][i];
         
-        for (Int j = 0; j < ge.m_numRefPicsActive; j++)
+        for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++)
         {        
-          if ( m_directRefLayers[ currLayerIdInVps ][ ge.m_interLayerPredLayerIdc[ j ]] == refLayerIdInVps )
+          if ( m_directRefLayers[ curLayerIdInVps ][ geCur.m_interLayerPredLayerIdc[ j ]] == refLayerIdInVps )
           {
-            maxTid = std::max( maxTid, ge.m_temporalId ); 
+            maxTid = std::max( maxTid, geRef.m_temporalId ); 
           }
         }
@@ -1037,5 +1039,5 @@
     {        
       GOPEntry ge =  m_GOPListMvc[currLayerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
-      maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numRefPicsActive <= 1); 
+      maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); 
     }            
   }
@@ -1069,4 +1071,17 @@
   return maxVec;
 }
+
+
+Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps )
+{ 
+  const Int vpsNumProfileTierLevelMinus1 = 0; //TBD
+  vps.setVpsNumProfileTierLevelMinus1( vpsNumProfileTierLevelMinus1 ); 
+  
+  for (Int i = 0; i <= vps.getVpsNumProfileTierLevelMinus1(); i++ )
+  {
+    vps.setVpsProfilePresentFlag( i, true ); 
+  }
+}
+
 
 Void TAppEncTop::xSetLayerSets( TComVPS& vps )
@@ -1088,5 +1103,5 @@
   }
 
-  Int numAddOuputLayerSets = m_outputLayerSetIdx.size(); 
+  Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); 
   // Additional output layer sets + profileLevelTierIdx
   vps.setDefaultOneTargetOutputLayerFlag   ( m_defaultOneTargetOutputLayerFlag ); 
Index: branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.h	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.h	(revision 495)
@@ -119,5 +119,6 @@
   Void xSetDimensionIdAndLength   ( TComVPS& vps );
   Void xSetDependencies           ( TComVPS& vps );
-  Void xSetLayerSets( TComVPS& vps );
+  Void xSetLayerSets              ( TComVPS& vps );
+  Void xSetProfileTierLevel       ( TComVPS& vps );
   Int  xGetMax( std::vector<Int>& vec);
 #endif
@@ -131,5 +132,4 @@
 #else
   TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
- 
 #endif
 };// END CLASS DEFINITION TAppEncTop
Index: branches/HTM-DEV-0.3-dev0/source/Lib/TAppCommon/program_options_lite.h
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/Lib/TAppCommon/program_options_lite.h	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/Lib/TAppCommon/program_options_lite.h	(revision 495)
@@ -375,17 +375,26 @@
       {
         std::string cNameBuffer;
-        std::string cDescriptionBuffer;
-
-        cNameBuffer       .resize( name.size() + 10 );
-        cDescriptionBuffer.resize( desc.size() + 10 );
+        std::string cDescBuffer;
+
+        cNameBuffer.resize( name.size() + 10 );
+        cDescBuffer.resize( desc.size() + 10 );
 
         storage.resize(uiMaxNum);
         for ( unsigned int uiK = 0; uiK < uiMaxNum; uiK++ )
         {
+          Bool duplicate = (uiK != 0); 
           // isn't there are sprintf function for string??
-          sprintf((char*) cNameBuffer.c_str()       ,name.c_str(),uiK,uiK);
-          sprintf((char*) cDescriptionBuffer.c_str(),desc.c_str(),uiK,uiK);
-
-          parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescriptionBuffer, uiK != 0 ));
+          sprintf((char*) cNameBuffer.c_str(),name.c_str(),uiK,uiK);
+
+          if ( !duplicate )
+          {          
+            sprintf((char*) cDescBuffer.c_str(),desc.c_str(),uiK,uiK);
+          }
+
+          cNameBuffer.resize( std::strlen(cNameBuffer.c_str()) );  
+          cDescBuffer.resize( std::strlen(cDescBuffer.c_str()) ); 
+          
+
+          parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescBuffer, duplicate ));
         }
 
Index: branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComRom.h
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComRom.h	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComRom.h	(revision 495)
@@ -162,5 +162,5 @@
 
 #ifndef ENC_DEC_TRACE
-# define ENC_DEC_TRACE 0
+# define ENC_DEC_TRACE 1
 #endif
 
Index: branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 495)
@@ -1457,4 +1457,12 @@
   }
 #if H_MV
+  for (Int lsIdx = 0; lsIdx < MAX_VPS_OP_SETS_PLUS1; lsIdx++ )
+  {  
+    for( Int layerId = 0; layerId < MAX_VPS_NUH_LAYER_ID_PLUS1; layerId++ )
+    {
+      m_layerIdIncludedFlag[lsIdx][layerId] = false; 
+    }
+  } 
+
   m_vpsNumberLayerSetsMinus1     = -1; 
   m_vpsNumProfileTierLevelMinus1 = -1; 
@@ -1472,5 +1480,5 @@
   {
     m_outputLayerSetIdxMinus1[i]  = -1; 
-    m_profileLevelTierIdx[i]      = -1; 
+    m_profileLevelTierIdx[i]      = 0; 
     for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++)
     {
@@ -1480,5 +1488,5 @@
   
   m_maxOneActiveRefLayerFlag = false; 
-  m_directDepTypeLenMinus2   = -1;         
+  m_directDepTypeLenMinus2   = 0;         
   
 
Index: branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 495)
@@ -674,6 +674,6 @@
   Int     getVpsNumProfileTierLevelMinus1( )                               { return m_vpsNumProfileTierLevelMinus1; } 
   
-  Void    setVpsProfilePresentFlag( Int layerSet, Bool val )               { m_vpsProfilePresentFlag[layerSet] = val;  }
-  Bool    getVpsProfilePresentFlag( Int layerSet )                         { return m_vpsProfilePresentFlag[layerSet]; }
+  Void    setVpsProfilePresentFlag( Int idx, Bool val )                    { m_vpsProfilePresentFlag[idx] = val;  }
+  Bool    getVpsProfilePresentFlag( Int idx )                              { return m_vpsProfilePresentFlag[idx]; }
 
   Void    setProfileRefMinus1( Int profileTierLevelIdx, Int val )          { m_profileRefMinus1[ profileTierLevelIdx ] = val;  } 
Index: branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 495)
@@ -57,5 +57,5 @@
 
 #ifndef HEVC_EXT
-#define HEVC_EXT                    2
+#define HEVC_EXT                    1
 #endif
 
Index: branches/HTM-DEV-0.3-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 495)
@@ -560,4 +560,8 @@
   UInt  uiCode;
   READ_CODE( 4,  uiCode, "sps_video_parameter_set_id");          pcSPS->setVPSId        ( uiCode );
+#if H_MV
+  if ( pcSPS->getLayerId() == 0 )
+  {
+#endif
   READ_CODE( 3,  uiCode, "sps_max_sub_layers_minus1" );          pcSPS->setMaxTLayers   ( uiCode+1 );
   READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" );               pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
@@ -566,7 +570,9 @@
     // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0
     assert( uiCode == 1 );
-  }
-  
+  }  
   parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
+#if H_MV
+  }
+#endif
   READ_UVLC(     uiCode, "sps_seq_parameter_set_id" );           pcSPS->setSPSId( uiCode );
   READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
@@ -726,5 +732,4 @@
 #else
     READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" );    pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false);
-    READ_FLAG( uiCode, "sps_extension2_flag");
     ////   sps_extension_vui_parameters( )
     if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() )
@@ -747,5 +752,5 @@
     ////   sps_extension_vui_parameters( ) END
     READ_UVLC( uiCode, "sps_shvc_reserved_zero_idc" ); 
-
+    READ_FLAG( uiCode, "sps_extension2_flag");
     if ( uiCode )
     {
@@ -756,4 +761,5 @@
       }
 #else
+      
       UInt uiCamParPrecision = 0; 
       Bool bCamParSlice      = false; 
@@ -839,5 +845,5 @@
 #if H_MV
   assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 );
-  READ_CODE( 6, uiCode, "vps_max_nuh_layer_id" );   pcVPS->setVpsMaxLayerId( uiCode );
+  READ_CODE( 6, uiCode, "vps_max_layer_id" );   pcVPS->setVpsMaxLayerId( uiCode );
 
   READ_UVLC(    uiCode, "vps_max_num_layer_sets_minus1" );               pcVPS->setVpsNumLayerSetsMinus1( uiCode );
@@ -950,5 +956,5 @@
     READ_CODE( 6,  uiCode, "vps_num_profile_tier_level_minus1" );  pcVPS->setVpsNumProfileTierLevelMinus1( uiCode );
 
-    for( Int i = 1; i <= pcVPS->getVpsNumberLayerSetsMinus1(); i++ )
+    for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ )
     {
       READ_FLAG(  uiCode, "vps_profile_present_flag[i]" );    pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 );
@@ -986,8 +992,11 @@
       {        
         READ_UVLC( uiCode,      "output_layer_set_idx_minus1[i]" ); pcVPS->setOutputLayerSetIdxMinus1( i, uiCode ); 
-        for( Int j = 0; j <= pcVPS->getNumLayersInIdList( j ); j++ )
+        for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ )
         {
           READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); 
-        }
+        }        
+      }
+      if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
+      {      
         READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" );   pcVPS->setProfileLevelTierIdx( i , uiCode ); 
       }
@@ -1001,5 +1010,8 @@
       for( Int j = 0; j < i; j++ )
       {
-        READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2,  uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode);
+        if (pcVPS->getDirectDependencyFlag( i, j) )
+        {        
+          READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2,  uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode);
+        }
       }
     }
@@ -1156,4 +1168,7 @@
       rps->setNumberOfPictures(0);
       rpcSlice->setRPS(rps);
+#if H_MV
+      rpcSlice->setEnableTMVPFlag(false);
+#endif
     }
     else
Index: branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 495)
@@ -449,7 +449,14 @@
 #endif
   WRITE_CODE( pcSPS->getVPSId (),          4,       "sps_video_parameter_set_id" );
+#if H_MV
+  if ( pcSPS->getLayerId() == 0 )
+  {
+#endif
   WRITE_CODE( pcSPS->getMaxTLayers() - 1,  3,       "sps_max_sub_layers_minus1" );
   WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0,                             "sps_temporal_id_nesting_flag" );
   codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
+#if H_MV
+}
+#endif
   WRITE_UVLC( pcSPS->getSPSId (),                   "sps_seq_parameter_set_id" );
   WRITE_UVLC( pcSPS->getChromaFormatIdc (),         "chroma_format_idc" );
@@ -795,8 +802,11 @@
     {      
       WRITE_UVLC( pcVPS->getOutputLayerSetIdxMinus1( i ),      "output_layer_set_idx_minus1[i]" );
-      for( Int j = 0; j <= pcVPS->getNumLayersInIdList( j ); j++ )
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1 ; j++ )
       {
         WRITE_FLAG( pcVPS->getOutputLayerFlag( i, j) ? 1 : 0, "output_layer_flag" );
-      }
+      }      
+    }
+    if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
+    {      
       WRITE_CODE( pcVPS->getProfileLevelTierIdx( i ), pcVPS->getProfileLevelTierIdxLen() ,"profile_level_tier_idx[ i ]" );   
     }
@@ -810,5 +820,9 @@
       for( Int j = 0; j < i; j++ )
       {
-        WRITE_CODE( pcVPS->getDirectDependencyType( i, j ),pcVPS->getDirectDepTypeLenMinus2( ) + 2,  "direct_dependency_type[i][j]" );
+        if (pcVPS->getDirectDependencyFlag( i, j) )
+        {        
+          assert ( pcVPS->getDirectDependencyType( i, j ) != -1 ); 
+          WRITE_CODE( pcVPS->getDirectDependencyType( i, j ),pcVPS->getDirectDepTypeLenMinus2( ) + 2,  "direct_dependency_type[i][j]" );
+        }
       }
     }
@@ -1171,5 +1185,4 @@
       {
         WRITE_FLAG( pcSlice->getAltCollocatedIndicationFlag( ) ? 1 : 0 , "alt_collocated_indication_flag" );
-
         if( pcSlice->getAltCollocatedIndicationFlag() && pcSlice->getNumActiveMotionPredRefLayers() > 1 ) 
         {          
Index: branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 494)
+++ branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 495)
@@ -835,4 +835,10 @@
       pcSlice->setEnableTMVPFlag(0);
     }
+#if H_MV
+    if( pcSlice->getIdrPicFlag() )
+    {
+      pcSlice->setEnableTMVPFlag(0);
+    }
+#endif
 
 #if H_3D_VSO
