Index: branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1365)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1366)
@@ -2025,5 +2025,5 @@
   Int                        m_iAssociatedIRAP;
   NalUnitType                m_iAssociatedIRAPType;
-  TComReferencePictureSet*   m_pcRPS;
+  const TComReferencePictureSet*   m_pcRPS;
   TComReferencePictureSet    m_LocalRPS;
   Int                        m_iBDidx;
@@ -2170,6 +2170,6 @@
   Void                        setSaoEnabledFlag(ChannelType chType, Bool s)          {m_saoEnabledFlag[chType] =s;                                   }
   Bool                        getSaoEnabledFlag(ChannelType chType) const            { return m_saoEnabledFlag[chType];                              }
-  Void                        setRPS( TComReferencePictureSet *pcRPS )               { m_pcRPS = pcRPS;                                              }
-  TComReferencePictureSet*    getRPS()                                               { return m_pcRPS;                                               }
+  Void                        setRPS( const TComReferencePictureSet *pcRPS )         { m_pcRPS = pcRPS;                                              }
+  const TComReferencePictureSet*    getRPS()                                               { return m_pcRPS;                                               }
   TComReferencePictureSet*    getLocalRPS()                                          { return &m_LocalRPS;                                           }
 
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1365)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1366)
@@ -1162,5 +1162,5 @@
 
               TComSlice *slice = dpbPic->getSlice(i);
-              TComReferencePictureSet *rps = slice->getRPS();
+              TComReferencePictureSet *rps = slice->getLocalRPS();
               slice->setPOC( slice->getPOC() - deltaPocVal );
 
@@ -1170,4 +1170,7 @@
                 rps->setPOC( j, rps->getPOC(j) - deltaPocVal );
               }
+
+              slice->setRPS(rps);
+
               // Also adjust the value of refPOC
               for(Int k = 0; k < 2; k++)  // For List 0 and List 1
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1365)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1366)
@@ -1926,5 +1926,5 @@
 #endif
     m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
-    pcSlice->getRPS()->setNumberOfLongtermPictures(0);
+//    pcSlice->getRPS()->setNumberOfLongtermPictures(0);
     if (!m_pcCfg->getEfficientFieldIRAPEnabled())
     {
@@ -3544,9 +3544,11 @@
 Void TEncGOP::arrangeLongtermPicturesInRPS(TComSlice *pcSlice, TComList<TComPic*>& rcListPic)
 {
-  TComReferencePictureSet *rps = pcSlice->getRPS();
-  if(!rps->getNumberOfLongtermPictures())
+  if(pcSlice->getRPS()->getNumberOfLongtermPictures() == 0)
   {
     return;
   }
+  // we can only modify the local RPS!
+  assert (pcSlice->getRPSidx()==-1);
+  TComReferencePictureSet *rps = pcSlice->getLocalRPS();
 
   // Arrange long-term reference pictures in the correct order of LSB and MSB,
@@ -4013,5 +4015,5 @@
             {
               TComSlice *dpbPicSlice = dpbPic->getSlice( i );
-              TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS();
+              TComReferencePictureSet *dpbPicRps = dpbPicSlice->getLocalRPS();
 
               // Decrement POC of slice
@@ -4023,4 +4025,6 @@
                 dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal );
               }
+              
+              dpbPicSlice->setRPS(dpbPicRps);
 
               // Decrement value of refPOC
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1365)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1366)
@@ -1512,8 +1512,6 @@
   }
 
-  TComReferencePictureSet *rps=slice->getLocalRPS();
-  (*rps) = *(slice->getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx()));
+  const TComReferencePictureSet *rps = (slice->getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx()));
   slice->setRPS(rps);
-  slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures());
 }
 
