 source/Lib/CommonLib/ContextModelling.h | 13 +++++++++++--
 source/Lib/CommonLib/TypeDef.h          |  3 +++
 source/Lib/CommonLib/UnitTools.cpp      |  2 ++
 source/Lib/CommonLib/UnitTools.h        |  2 ++
 source/Lib/DecoderLib/CABACReader.cpp   | 11 +++++++++++
 source/Lib/EncoderLib/CABACWriter.cpp   | 11 +++++++++++
 source/Lib/EncoderLib/EncCu.cpp         | 15 +++++++++++++++
 source/Lib/EncoderLib/EncModeCtrl.cpp   | 19 +++++++++++++++++--
 source/Lib/EncoderLib/EncModeCtrl.h     |  2 +-
 9 files changed, 73 insertions(+), 5 deletions(-)

diff --git a/source/Lib/CommonLib/ContextModelling.h b/source/Lib/CommonLib/ContextModelling.h
index fbb48aa..8e88f06 100644
--- a/source/Lib/CommonLib/ContextModelling.h
+++ b/source/Lib/CommonLib/ContextModelling.h
@@ -536,15 +536,24 @@ class CUCtx
 {
 public:
   CUCtx()              : isDQPCoded(false), isChromaQpAdjCoded(false),
+#if FIX_ISSUE_91_DQP
+                         isQPPredicted(false),
+#endif
                          numNonZeroCoeffNonTs(0) {}
   CUCtx(int _qp)       : isDQPCoded(false), isChromaQpAdjCoded(false),
+#if FIX_ISSUE_91_DQP
+                         isQPPredicted(false),
+#endif
                          numNonZeroCoeffNonTs(0), qp(_qp) {}
   ~CUCtx() {}
 public:
   bool      isDQPCoded;
   bool      isChromaQpAdjCoded;
-  uint32_t      numNonZeroCoeffNonTs;
-  int8_t     qp;                   // used as a previous(last) QP and for QP prediction
+#if FIX_ISSUE_91_DQP
+  bool      isQPPredicted;
+#endif
+  uint32_t  numNonZeroCoeffNonTs;
+  int8_t    qp;                   // used as a previous(last) QP and for QP prediction
 };
 
 class MergeCtx
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 9693ab6..23d9024 100644
--- a/source/Lib/CommonLib/TypeDef.h
+++ b/source/Lib/CommonLib/TypeDef.h
@@ -54,6 +54,9 @@
 #define BMS_TOOLS                                         1 // Inclusion of BMS only tools (which include JEM tools) into compiled executable
 #endif
 
+#define FIX_ISSUE_91_DQP                                  1
+#define FIX_NO_REUSE_FOR_DT                               1
+
 #if BMS_TOOLS
 #define JEM_TOOLS                                         1
 #define JVET_K0076_CPR                                    1 // current picture referencing or intra block copy mode
diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp
index 2726185..c984ee1 100644
--- a/source/Lib/CommonLib/UnitTools.cpp
+++ b/source/Lib/CommonLib/UnitTools.cpp
@@ -388,6 +388,7 @@ int CU::predictQP( const CodingUnit& cu, const int prevQP )
   return ( a + b + 1 ) >> 1;
 }
 
+#if !FIX_ISSUE_91_DQP
 bool CU::isQGStart( const CodingUnit& cu )
 {
   const SPS &sps = *cu.cs->sps;
@@ -397,6 +398,7 @@ bool CU::isQGStart( const CodingUnit& cu )
          ( cu.blocks[cu.chType].y % ( ( 1 << ( g_aucLog2[sps.getMaxCUHeight()] - pps.getMaxCuDQPDepth() ) ) >> getChannelTypeScaleY( cu.chType, cu.chromaFormat ) ) ) == 0;
 }
 
+#endif
 uint32_t CU::getNumPUs( const CodingUnit& cu )
 {
   uint32_t cnt = 0;
diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h
index 31a007e..91ce937 100644
--- a/source/Lib/CommonLib/UnitTools.h
+++ b/source/Lib/CommonLib/UnitTools.h
@@ -87,7 +87,9 @@ namespace CU
   uint32_t getCtuAddr                     (const CodingUnit &cu);
 
   int  predictQP                      (const CodingUnit& cu, const int prevQP );
+#if !FIX_ISSUE_91_DQP
   bool isQGStart                      (const CodingUnit& cu); // check if start of a Quantization Group
+#endif
 
   uint32_t getNumPUs                      (const CodingUnit& cu);
   void addPUs                         (      CodingUnit& cu);
diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp
index 7b32fb3..b9bed4a 100644
--- a/source/Lib/DecoderLib/CABACReader.cpp
+++ b/source/Lib/DecoderLib/CABACReader.cpp
@@ -964,6 +964,9 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU
   if( pps.getUseDQP() && partitioner.currDepth <= pps.getMaxCuDQPDepth() )
   {
     cuCtx.isDQPCoded          = false;
+#if FIX_ISSUE_91_DQP
+    cuCtx.isQPPredicted       = false;
+#endif
   }
   if( cs.slice->getUseChromaQpAdj() && partitioner.currDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() )
   {
@@ -1143,10 +1146,18 @@ bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU
 #endif
 
   // Predict QP on start of quantization group
+#if FIX_ISSUE_91_DQP
+  if( pps.getUseDQP() && !cuCtx.isDQPCoded && !cuCtx.isQPPredicted )
+  {
+    cuCtx.qp = CU::predictQP( cu, cuCtx.qp );
+    cuCtx.isQPPredicted = true;
+  }
+#else
   if( pps.getUseDQP() && !cuCtx.isDQPCoded && CU::isQGStart( cu ) )
   {
     cuCtx.qp = CU::predictQP( cu, cuCtx.qp );
   }
+#endif
 
   cu.qp          = cuCtx.qp;        //NOTE: CU QP can be changed by deltaQP signaling at TU level
   cu.chromaQpAdj = cs.chromaQpAdj;  //NOTE: CU chroma QP adjustment can be changed by adjustment signaling at TU level
diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp
index a4d9a7a..1dca54b 100644
--- a/source/Lib/EncoderLib/CABACWriter.cpp
+++ b/source/Lib/EncoderLib/CABACWriter.cpp
@@ -1013,6 +1013,9 @@ void CABACWriter::coding_tree( const CodingStructure& cs, Partitioner& partition
   if( pps.getUseDQP() && partitioner.currDepth <= pps.getMaxCuDQPDepth() )
   {
     cuCtx.isDQPCoded          = false;
+#if FIX_ISSUE_91_DQP
+    cuCtx.isQPPredicted       = false;
+#endif
   }
   if( cs.slice->getUseChromaQpAdj() && partitioner.currDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() )
   {
@@ -1159,10 +1162,18 @@ void CABACWriter::coding_tree( const CodingStructure& cs, Partitioner& partition
   }
 
   // Predict QP on start of quantization group
+#if FIX_ISSUE_91_DQP
+  if( pps.getUseDQP() && !cuCtx.isDQPCoded && !cuCtx.isQPPredicted )
+  {
+    cuCtx.qp = CU::predictQP( cu, cuCtx.qp );
+    cuCtx.isQPPredicted = true;
+  }
+#else
   if( pps.getUseDQP() && !cuCtx.isDQPCoded && CU::isQGStart( cu ) )
   {
     cuCtx.qp = CU::predictQP( cu, cuCtx.qp );
   }
+#endif
 
 #if JVET_K0346
   if (!cs.slice->isIntra() && m_EncCu)
diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp
index 51a115e..b379155 100644
--- a/source/Lib/EncoderLib/EncCu.cpp
+++ b/source/Lib/EncoderLib/EncCu.cpp
@@ -2049,6 +2049,10 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct
   m_pcInterSearch->subBlockOBMC      ( cu );
 #endif
 
+#if FIX_ISSUE_91_DQP
+  auto *oldTempCS = tempCS;
+#endif
+
   xEncodeInterResidual(tempCS, bestCS, partitioner, encTestMode, 0
 #if JEM_TOOLS || JVET_K0357_AMVR
     , NULL
@@ -2060,9 +2064,20 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct
 
   if( ! (encTestMode.lossless || hasNoResidual) )
   {
+#if FIX_ISSUE_91_DQP
+    if( tempCS != oldTempCS )
+    {
+#endif
     tempCS->initStructData( encTestMode.qp, encTestMode.lossless );
     tempCS->copyStructure( *bestCS, partitioner.chType );
     tempCS->getPredBuf().copyFrom( bestCS->getPredBuf() );
+#if FIX_ISSUE_91_DQP
+    }
+    else
+    {
+      tempCS->clearTUs();
+    }
+#endif
 
     xEncodeInterResidual(tempCS, bestCS, partitioner, encTestMode, 1
 #if JEM_TOOLS || JVET_K0357_AMVR
diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp
index a593e4e..44273df 100644
--- a/source/Lib/EncoderLib/EncModeCtrl.cpp
+++ b/source/Lib/EncoderLib/EncModeCtrl.cpp
@@ -766,7 +766,14 @@ bool BestEncInfoCache::isValid( const CodingStructure& cs, const Partitioner& pa
 
   BestEncodingInfo& encInfo = *m_bestEncInfo[idx1][idx2][idx3][idx4];
 
-  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != encInfo.cu || !isTheSameNbHood( encInfo.cu, partitioner ) 
+#if FIX_NO_REUSE_FOR_DT
+  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != encInfo.cu || !isTheSameNbHood( encInfo.cu, partitioner )
+#else
+  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != CS::getArea( cs, encInfo.cu, partitioner.chType ) || !isTheSameNbHood( encInfo.cu, partitioner ) 
+#endif
+#if FIX_ISSUE_91_DQP
+    || partitioner.currDepth <= cs.pps->getMaxCuDQPDepth() || cs.currQP[partitioner.chType] != encInfo.cu.qp
+#endif
 #if JVET_K0076_CPR
     || encInfo.cu.ibc
 #endif
@@ -787,7 +794,15 @@ bool BestEncInfoCache::setCsFrom( CodingStructure& cs, EncTestMode& testMode, co
 
   BestEncodingInfo& encInfo = *m_bestEncInfo[idx1][idx2][idx3][idx4];
 
-  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != encInfo.cu || !isTheSameNbHood( encInfo.cu, partitioner ) )
+#if FIX_NO_REUSE_FOR_DT
+  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != encInfo.cu || !isTheSameNbHood( encInfo.cu, partitioner )
+#else
+  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != CS::getArea( cs, encInfo.cu, partitioner.chType ) || !isTheSameNbHood( encInfo.cu, partitioner )
+#endif
+#if FIX_ISSUE_91_DQP
+    || partitioner.currDepth <= cs.pps->getMaxCuDQPDepth() || encInfo.cu.qp != cs.currQP[partitioner.chType]
+#endif
+    )
   {
     return false;
   }
diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h
index 4b95630..6449314 100644
--- a/source/Lib/EncoderLib/EncModeCtrl.h
+++ b/source/Lib/EncoderLib/EncModeCtrl.h
@@ -280,7 +280,7 @@ protected:
   int                   m_lumaQPOffset;
 #endif
   bool                  m_fastDeltaQP;
-  static_vector<ComprCUCtx, ( MAX_CU_DEPTH << 2 )> m_ComprCUCtxList;
+  std::vector<ComprCUCtx> m_ComprCUCtxList;
 #if ENABLE_SPLIT_PARALLELISM
   int                   m_runNextInParallel;
 #endif
