diff --git a/cfg/encoder_intra_vtm.cfg b/cfg/encoder_intra_vtm.cfg
index 9fe357d1596f37aeba8ab80ed6d11d684720bbc9..57b9ef540bce9ef7350d448a7ca853f49fcdfeab 100644
--- a/cfg/encoder_intra_vtm.cfg
+++ b/cfg/encoder_intra_vtm.cfg
@@ -101,7 +101,7 @@ MTS                          : 1
 MTSIntraMaxCand              : 3
 MTSInterMaxCand              : 4
 SBT                          : 1
-LFNST			     : 1
+LFNST                        : 1
 ISP                          : 1
 Affine                       : 1
 SubPuMvp                     : 1
@@ -125,7 +125,7 @@ ISPFast                      : 1
 FastMrg                      : 1
 AMaxBT                       : 1
 FastMIP                      : 1
-FastLFNST		     : 1
+FastLFNST                    : 1
 
 # Encoder optimization tools
 AffineAmvrEncOpt             : 0
diff --git a/cfg/encoder_lowdelay_P_vtm.cfg b/cfg/encoder_lowdelay_P_vtm.cfg
index 1e3179dfc207af63b63bcc250894a73c77c36b7b..fcc83ed92956b95f44f4996eea69342cb63737ca 100644
--- a/cfg/encoder_lowdelay_P_vtm.cfg
+++ b/cfg/encoder_lowdelay_P_vtm.cfg
@@ -145,7 +145,7 @@ FastLocalDualTree            : 1
 
 # Encoder optimization tools
 AffineAmvrEncOpt             : 0
-MmvdDisNum		     : 6
+MmvdDisNum                   : 6
 ### DO NOT ADD ANYTHING BELOW THIS LINE ###
 ### DO NOT DELETE THE EMPTY LINE BELOW ###
 
diff --git a/cfg/encoder_lowdelay_vtm.cfg b/cfg/encoder_lowdelay_vtm.cfg
index 4256511de22eaba8f8e2f3a34ca47a6b63f23076..a1c98ae3c685dd7215ea4f02a514e0f797c09a3e 100644
--- a/cfg/encoder_lowdelay_vtm.cfg
+++ b/cfg/encoder_lowdelay_vtm.cfg
@@ -149,7 +149,7 @@ FastLocalDualTree            : 1
 
 # Encoder optimization tools
 AffineAmvrEncOpt             : 0
-MmvdDisNum		     : 6
+MmvdDisNum                   : 6
 ### DO NOT ADD ANYTHING BELOW THIS LINE ###
 ### DO NOT DELETE THE EMPTY LINE BELOW ###
 
diff --git a/cfg/encoder_randomaccess_vtm.cfg b/cfg/encoder_randomaccess_vtm.cfg
index fdada7ba5ea90be018b75e0ca9775a55ba0080ab..7c4404bdfca11c24f7cdc4619bbfe57e25084d40 100644
--- a/cfg/encoder_randomaccess_vtm.cfg
+++ b/cfg/encoder_randomaccess_vtm.cfg
@@ -130,7 +130,7 @@ MTS                          : 1
 MTSIntraMaxCand              : 3
 MTSInterMaxCand              : 4
 SBT                          : 1
-LFNST			     : 1
+LFNST                        : 1
 ISP                          : 1
 MMVD                         : 1
 Affine                       : 1
@@ -163,12 +163,12 @@ ISPFast                      : 0
 FastMrg                      : 1
 AMaxBT                       : 1
 FastMIP                      : 0
-FastLFNST		     : 0
+FastLFNST                    : 0
 FastLocalDualTree            : 0
 
 # Encoder optimization tools
 AffineAmvrEncOpt             : 1
-MmvdDisNum		     : 6
+MmvdDisNum                   : 6
 ### DO NOT ADD ANYTHING BELOW THIS LINE ###
 ### DO NOT DELETE THE EMPTY LINE BELOW ###
 
diff --git a/source/App/StreamMergeApp/StreamMergeApp.cpp b/source/App/StreamMergeApp/StreamMergeApp.cpp
index de13c3a139890470c365c3d76777cc7f2a766e7e..365bb7bbb9b94b83bb3ada374a9b3c52b8416cbf 100644
--- a/source/App/StreamMergeApp/StreamMergeApp.cpp
+++ b/source/App/StreamMergeApp/StreamMergeApp.cpp
@@ -241,7 +241,7 @@ void StreamMergeApp::writeNewVPS(ostream& out, int nLayerId, int nTemporalId)
   OutputBitstream bsNALUHeader;
   static const uint8_t start_code_prefix[] = { 0,0,0,1 };
 
-  bsNALUHeader.write(1, 1);    		       // zero_tid_required_flag
+  bsNALUHeader.write(1, 1);                // zero_tid_required_flag
   bsNALUHeader.write(nTemporalId + 1, 3);                // nuh_temporal_id_plus1
   uint32_t nalUnitTypeLsb = NAL_UNIT_VPS - (1 << 4);
   bsNALUHeader.write(nalUnitTypeLsb, 4);   // nal_unit_type_lsb
diff --git a/source/Lib/CommonLib/CodingStatistics.h b/source/Lib/CommonLib/CodingStatistics.h
index 41a395feb8dc6bcf9b96b0356bd7e5f2e3936022..bb470c6967bf2cd8b272af157b8159469018daa9 100644
--- a/source/Lib/CommonLib/CodingStatistics.h
+++ b/source/Lib/CommonLib/CodingStatistics.h
@@ -95,9 +95,9 @@ enum CodingStatisticsType
   STATS__CABAC_BITS__ESCAPE_BITS_TS,
 #endif
   STATS__CABAC_BITS__SAO,
+  STATS__CABAC_BITS__LFNST,
   STATS__CABAC_BITS__ALF,
   STATS__CABAC_TRM_BITS,
-  STATS__CABAC_BITS__LFNST,
   STATS__CABAC_FIXED_BITS,
   STATS__CABAC_PCM_ALIGN_BITS,
   STATS__CABAC_PCM_CODE_BITS,
@@ -554,6 +554,9 @@ private:
           if( i == STATS__CABAC_INITIALISATION && sCABACorig.bits != 0 )
           {
             thisCABACbits += cr;
+#if EPBINCOUNT_FIX
+            sCABACorig.count = 0;
+#endif
             cr = 0;
           }
           sCABAC.bits       = thisCABACbits;
@@ -561,6 +564,12 @@ private:
           sCABAC.sum        = sCABACorig.sum;
           sCABAC.classCount = classCounts[i];
         }
+#if EPBINCOUNT_FIX
+        if (i == STATS__BYTE_ALIGNMENT_BITS || i == STATS__TRAILING_BITS || i == STATS__NAL_UNIT_HEADER_BITS || i == STATS__EMULATION_PREVENTION_3_BYTES)
+        {
+          sEP.count = 0;
+        }
+#endif
         uint32_t wIdx = CodingStatisticsClassType::GetSubClassWidth( c );
         uint32_t hIdx = CodingStatisticsClassType::GetSubClassHeight( c );
         OutputLine( pName, ':', wIdx, hIdx, CodingStatisticsClassType::GetSubClassString( c ), sCABAC, sEP );
@@ -934,6 +943,9 @@ public:
           if (i == STATS__CABAC_INITIALISATION && sCABACorig.bits != 0)
           {
             thisCABACbits += cr;
+#if EPBINCOUNT_FIX
+            sCABACorig.count = 0;
+#endif
             cr = 0;
           }
           sCABAC.bits = thisCABACbits;
@@ -941,6 +953,12 @@ public:
           sCABAC.sum = sCABACorig.sum;
           sCABAC.classCount = classCounts[i];
         }
+#if EPBINCOUNT_FIX
+        if ( i == STATS__BYTE_ALIGNMENT_BITS || i == STATS__TRAILING_BITS || i == STATS__NAL_UNIT_HEADER_BITS || i == STATS__EMULATION_PREVENTION_3_BYTES )
+        {
+          sEP.count = 0;
+        }
+#endif
 
         if( i != STATS__NAL_UNIT_TOTAL_BODY )
         {
diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp
index 0e97c92f19bd72f750b604bd0b7ecc65f1676f1d..48be9f5c749164e31aa911005326da97486e5480 100644
--- a/source/Lib/CommonLib/DepQuant.cpp
+++ b/source/Lib/CommonLib/DepQuant.cpp
@@ -886,10 +886,10 @@ namespace DQIntern
 #define RICEMAX 32
   const int32_t g_goRiceBits[4][RICEMAX] =
   {
-      { 32768,	65536,	98304,	131072,	163840,	196608,	262144,	262144,	327680,	327680,	327680,	327680,	393216,	393216,	393216,	393216,	393216,	393216,	393216,	393216,	458752,	458752,	458752,	458752,	458752,	458752,	458752,	458752,	458752,	458752,	458752,	458752},
-      { 65536,	65536,	98304,	98304,	131072,	131072,	163840,	163840,	196608,	196608,	229376,	229376,	294912,	294912,	294912,	294912,	360448,	360448,	360448,	360448,	360448,	360448,	360448,	360448,	425984,	425984,	425984,	425984,	425984,	425984,	425984,	425984},
-      { 98304,	98304,	98304,	98304,	131072,	131072,	131072,	131072,	163840,	163840,	163840,	163840,	196608,	196608,	196608,	196608,	229376,	229376,	229376,	229376,	262144,	262144,	262144,	262144,	327680,	327680,	327680,	327680,	327680,	327680,	327680,	327680},
-      { 131072,	131072,	131072,	131072,	131072,	131072,	131072,	131072,	163840,	163840,	163840,	163840,	163840,	163840,	163840,	163840,	196608,	196608,	196608,	196608,	196608,	196608,	196608,	196608,	229376,	229376,	229376,	229376,	229376,	229376,	229376,	229376}
+    { 32768,  65536,  98304, 131072, 163840, 196608, 262144, 262144, 327680, 327680, 327680, 327680, 393216, 393216, 393216, 393216, 393216, 393216, 393216, 393216, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752, 458752},
+    { 65536,  65536,  98304,  98304, 131072, 131072, 163840, 163840, 196608, 196608, 229376, 229376, 294912, 294912, 294912, 294912, 360448, 360448, 360448, 360448, 360448, 360448, 360448, 360448, 425984, 425984, 425984, 425984, 425984, 425984, 425984, 425984},
+    { 98304,  98304,  98304,  98304, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 262144, 262144, 262144, 262144, 327680, 327680, 327680, 327680, 327680, 327680, 327680, 327680},
+    {131072, 131072, 131072, 131072, 131072, 131072, 131072, 131072, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 163840, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 196608, 229376, 229376, 229376, 229376, 229376, 229376, 229376, 229376}
   };
 
   class State
@@ -1640,10 +1640,10 @@ namespace DQIntern
     for( ; firstTestPos >= 0; firstTestPos-- )
     {
       if (zeroOutforThres && (tuPars.m_scanId2BlkPos[firstTestPos].x >= ((tuPars.m_width == 32 && zeroOut) ? 16 : 32)
-			                     || tuPars.m_scanId2BlkPos[firstTestPos].y >= ((tuPars.m_height == 32 && zeroOut) ? 16 : 32))) 
+                           || tuPars.m_scanId2BlkPos[firstTestPos].y >= ((tuPars.m_height == 32 && zeroOut) ? 16 : 32)))
         continue;
       TCoeff thresTmp = (enableScalingLists) ? TCoeff(thres / (4 * quantCoeff[tuPars.m_scanId2BlkPos[firstTestPos].idx]))
-			                                       : TCoeff(thres / (4 * defaultQuantisationCoefficient));
+                                             : TCoeff(thres / (4 * defaultQuantisationCoefficient));
 
       if (abs(tCoeff[tuPars.m_scanId2BlkPos[firstTestPos].idx]) > thresTmp)
       {
diff --git a/source/Lib/CommonLib/Picture.cpp b/source/Lib/CommonLib/Picture.cpp
index a32727d252c738d8f5f1874d7b631bc489735548..642a84593a141bd410052c677b2847086f4e5828 100644
--- a/source/Lib/CommonLib/Picture.cpp
+++ b/source/Lib/CommonLib/Picture.cpp
@@ -471,11 +471,14 @@ void BrickMap::create( const SPS& sps, const PPS& pps )
   numTileRows    = pps.getNumTileRowsMinus1() + 1;
   numTiles       = numTileColumns * numTileRows;
 
-  const uint32_t numCtusInFrame = pcv->sizeInCtus;
+  const size_t numCtusInFrame = pcv->sizeInCtus;
+
   brickIdxRsMap    = new uint32_t[numCtusInFrame];
-  brickIdxBsMap    = new uint32_t[numCtusInFrame];
-  ctuBsToRsAddrMap = new uint32_t[numCtusInFrame+1];
-  ctuRsToBsAddrMap = new uint32_t[numCtusInFrame+1];
+  brickIdxBsMap    = new uint32_t[numCtusInFrame + 1];
+  ctuBsToRsAddrMap = new uint32_t[numCtusInFrame + 1];
+  ctuRsToBsAddrMap = new uint32_t[numCtusInFrame + 1];
+
+  brickIdxBsMap[numCtusInFrame] = ~0u;   // Initialize last element to some large value
 
   initBrickMap( sps, pps );
 
diff --git a/source/Lib/CommonLib/Quant.cpp b/source/Lib/CommonLib/Quant.cpp
index f3adf0b586ba6861774d9e82b3af2edc10fc0bac..7d724e3c3a33230b9022b12299dbd3efe41cf0f3 100644
--- a/source/Lib/CommonLib/Quant.cpp
+++ b/source/Lib/CommonLib/Quant.cpp
@@ -602,8 +602,8 @@ void Quant::setScalingList(ScalingList *scalingList, const int maxLog2TrDynamicR
     {
       if (sizew == sizeh || (sizew == SCALING_LIST_1x1 && sizeh<SCALING_LIST_4x4) || (sizeh == SCALING_LIST_1x1 && sizew<SCALING_LIST_4x4)) continue;
       for (uint32_t list = 0; list < SCALING_LIST_NUM; list++) //9
-		  {
-			  for (int qp = minimumQp; qp < maximumQp; qp++)
+      {
+        for (int qp = minimumQp; qp < maximumQp; qp++)
         {
           xSetRecScalingListEnc(scalingList, list, sizew, sizeh, qp);
           xSetRecScalingListDec(*scalingList, list, sizew, sizeh, qp);
diff --git a/source/Lib/CommonLib/QuantRDOQ.cpp b/source/Lib/CommonLib/QuantRDOQ.cpp
index add6b384f439d91995bc054809056ede253450b6..5414d867f6435d4b835f71cf716ffeaa0659c97b 100644
--- a/source/Lib/CommonLib/QuantRDOQ.cpp
+++ b/source/Lib/CommonLib/QuantRDOQ.cpp
@@ -149,9 +149,9 @@ inline uint32_t QuantRDOQ::xGetCodedLevel( double&            rd64CodedCost,
     double dErr         = double( lLevelDouble  - ( Intermediate_Int(uiAbsLevel) << iQBits ) );
 
 #if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
-	double dCurrCost    = dErr * dErr * errorScale + xGetICost( xGetICRate( uiAbsLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, ui16AbsGoRice, true, maxLog2TrDynamicRange ) );
+    double dCurrCost    = dErr * dErr * errorScale + xGetICost( xGetICRate( uiAbsLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, ui16AbsGoRice, true, maxLog2TrDynamicRange ) );
 #else
-	double dCurrCost    = dErr * dErr * errorScale + xGetICost( xGetICRate( uiAbsLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, ui16AbsGoRice, true, maxLog2TrDynamicRange ) );
+    double dCurrCost    = dErr * dErr * errorScale + xGetICost( xGetICRate( uiAbsLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, ui16AbsGoRice, true, maxLog2TrDynamicRange ) );
 #endif
     dCurrCost          += dCurrCostSig;
 
diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp
index bb22694f9a10e9d32d36c9a98b389d9317cba283..9dd63be0940057d30ab9e08024b0f88cd0173aa5 100644
--- a/source/Lib/CommonLib/Rom.cpp
+++ b/source/Lib/CommonLib/Rom.cpp
@@ -674,7 +674,7 @@ const char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] =
     "INTER1X1_LUMA",
     "INTER1X1_CHROMAU",
     "INTER1X1_CHROMAV"
-	},
+  },
   {
     "INTRA2X2_LUMA",
     "INTRA2X2_CHROMAU",
diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp
index e2db046f4e2d1b7340b19296a1870287829d4220..c63ac842aed892b2e120713e4bd371856ae9d4cc 100755
--- a/source/Lib/CommonLib/UnitTools.cpp
+++ b/source/Lib/CommonLib/UnitTools.cpp
@@ -3145,7 +3145,11 @@ void PU::getAffineControlPointCand(const PredictionUnit &pu, MotionInfo mi[4], i
   }
   affMrgType.interDirNeighbours[affMrgType.numValidMergeCand] = dir;
   affMrgType.affineType[affMrgType.numValidMergeCand] = curType;
+#if JVET_O0366_AFFINE_BCW
+  affMrgType.GBiIdx[affMrgType.numValidMergeCand] = (dir == 3) ? gbiIdx : GBI_DEFAULT;
+#else
   affMrgType.GBiIdx[affMrgType.numValidMergeCand] = gbiIdx;
+#endif
   affMrgType.numValidMergeCand++;
 
 
@@ -4604,19 +4608,18 @@ bool CU::isGBiIdxCoded( const CodingUnit &cu )
   {
     if( cu.firstPU->interDir == 3 )
     {
-		WPScalingParam *wp0;
-		WPScalingParam *wp1;
-		int refIdx0 = cu.firstPU->refIdx[REF_PIC_LIST_0];
-		int refIdx1 = cu.firstPU->refIdx[REF_PIC_LIST_1];
-
-		cu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0);
-		cu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1);
-		if ((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag
-			|| wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag)
-			)
-		{
-			return false;
-		}
+      WPScalingParam *wp0;
+      WPScalingParam *wp1;
+      int refIdx0 = cu.firstPU->refIdx[REF_PIC_LIST_0];
+      int refIdx1 = cu.firstPU->refIdx[REF_PIC_LIST_1];
+
+      cu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0);
+      cu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1);
+      if ((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag
+        || wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag))
+      {
+        return false;
+      }
       return true;
     }
   }
diff --git a/source/Lib/CommonLib/version.h b/source/Lib/CommonLib/version.h
index d0ec7faedfdf06610223ace0c1e31d7d23bded9f..a05fa29f46ffebec2553c21e9664e371f79bbaae 100644
--- a/source/Lib/CommonLib/version.h
+++ b/source/Lib/CommonLib/version.h
@@ -1,3 +1,3 @@
 #if ! defined( VTM_VERSION )
-#define VTM_VERSION "5.2"
+#define VTM_VERSION "6.0rc1"
 #endif
diff --git a/source/Lib/DecoderLib/AnnexBread.cpp b/source/Lib/DecoderLib/AnnexBread.cpp
index 2eaea4f7f94c9357a020335751a49859cfa5987c..fa684c9cd1a873ea0e8aacb2eed85a3a4117ecca 100644
--- a/source/Lib/DecoderLib/AnnexBread.cpp
+++ b/source/Lib/DecoderLib/AnnexBread.cpp
@@ -80,7 +80,7 @@ _byteStreamNALUnit(
     uint8_t leading_zero_8bits = bs.readByte();
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
 #if EPBINCOUNT_FIX
-    statBits.bits+=8; statBits.count+=8;
+    statBits.bits+=8;
 #else
     statBits.bits+=8; statBits.count++;
 #endif
@@ -102,7 +102,7 @@ _byteStreamNALUnit(
     uint8_t zero_byte = bs.readByte();
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
 #if EPBINCOUNT_FIX
-    statBits.bits+=8; statBits.count+=8;
+    statBits.bits+=8;
 #else
     statBits.bits+=8; statBits.count++;
 #endif
@@ -120,7 +120,7 @@ _byteStreamNALUnit(
   uint32_t start_code_prefix_one_3bytes = bs.readBytes(24/8);
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
 #if EPBINCOUNT_FIX
-  statBits.bits+=24; statBits.count+=24;
+  statBits.bits+=24;
 #else
   statBits.bits+=24; statBits.count+=3;
 #endif
@@ -176,7 +176,7 @@ _byteStreamNALUnit(
     uint8_t trailing_zero_8bits = bs.readByte();
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
 #if EPBINCOUNT_FIX
-    statBits.bits+=8; statBits.count+=8;
+    statBits.bits+=8;
 #else
     statBits.bits+=8; statBits.count++;
 #endif
diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index 312fdeb0b6ac310c52c2ce02ad5acf639538cbc0..398d19db66d28e1ebd6ae9613b9fbadb94cd5fa7 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -1894,8 +1894,8 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
 #endif
           apsId[i] = uiCode;
         }
-		
-		
+
+
         pcSlice->setAlfAPSs(apsId);
 #if JVET_O0616_400_CHROMA_SUPPORT
         if (bChroma)
@@ -2694,13 +2694,13 @@ void HLSyntaxReader::parseScalingList(ScalingList* scalingList)
           if (sizeId == SCALING_LIST_64x64)
           {
             code *= (SCALING_LIST_NUM / SCALING_LIST_PRED_MODES); // Adjust the decoded code for this size, to cope with the missing 32x32 chroma entries.
-	  }
+          }
 
           scalingList->setRefMatrixId (sizeId,listId,(uint32_t)((int)(listId)-(code)));
           if( sizeId > SCALING_LIST_8x8 )
           {
             scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId))));
-	  }
+          }
           scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId));
 
         }
diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h
index 5451185bd5408796a7c509999c036b9baa78d404..276e1f6088fce7fe7bc9e729ea2158e260ac2a15 100644
--- a/source/Lib/EncoderLib/EncCfg.h
+++ b/source/Lib/EncoderLib/EncCfg.h
@@ -235,8 +235,8 @@ protected:
   int       m_iGOPSize;
   RPLEntry  m_RPLList0[MAX_GOP];
   RPLEntry  m_RPLList1[MAX_GOP];
-  int		    m_numRPLList0;
-  int		    m_numRPLList1;
+  int       m_numRPLList0;
+  int       m_numRPLList1;
   GOPEntry  m_GOPList[MAX_GOP];
   int       m_maxDecPicBuffering[MAX_TLAYER];
   int       m_numReorderPics[MAX_TLAYER];
diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp
index f43124da887bb01c0abcc4f08daf530bc02a4253..e685bc02647fd655bf82a492bc778e77fa7300de 100644
--- a/source/Lib/EncoderLib/EncCu.cpp
+++ b/source/Lib/EncoderLib/EncCu.cpp
@@ -4601,11 +4601,11 @@ void EncCu::xEncodeInterResidual(   CodingStructure *&tempCS
   const int normalShiftTab[NUM_IMV_MODES] =
   {
     MV_PRECISION_INTERNAL - MV_PRECISION_QUARTER,
+    MV_PRECISION_INTERNAL - MV_PRECISION_INT,
+    MV_PRECISION_INTERNAL - MV_PRECISION_4PEL,
 #if JVET_O0057_ALTHPELIF
     MV_PRECISION_INTERNAL - MV_PRECISION_HALF,
 #endif
-    MV_PRECISION_INTERNAL - MV_PRECISION_INT,
-    MV_PRECISION_INTERNAL - MV_PRECISION_4PEL
   };
   // clang-format on
 
diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp
index 24478bcdbe9e578be327e82dc62d28ef060a66c4..35b046c30c70238868a137d97f6463e71cb11f6e 100644
--- a/source/Lib/EncoderLib/EncLib.cpp
+++ b/source/Lib/EncoderLib/EncLib.cpp
@@ -899,6 +899,9 @@ void EncLib::xInitSPS(SPS &sps)
   sps.setSplitConsOverrideEnabledFlag        ( m_useSplitConsOverride );
   sps.setMinQTSizes                          ( m_uiMinQT );
   sps.setMaxBTDepth                          ( m_uiMaxBTDepth, m_uiMaxBTDepthI, m_uiMaxBTDepthIChroma );
+  sps.setMaxBTSize                           ( std::min((int)m_CTUSize, MAX_BT_SIZE_INTER),
+                                               std::min((int)m_CTUSize, MAX_BT_SIZE),
+                                               std::min((int)m_CTUSize, MAX_BT_SIZE_C) );
   sps.setIDRRefParamListPresent              ( m_idrRefParamList );
   sps.setUseDualITree                        ( m_dualITree );
   sps.setUseLFNST                            ( m_LFNST );
diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp
index 8f46b9bc60dd96251e9b706c949bccde63af6d97..60d7fb57c4c00654965a33feaf7c6cac7d6407a1 100644
--- a/source/Lib/EncoderLib/EncModeCtrl.cpp
+++ b/source/Lib/EncoderLib/EncModeCtrl.cpp
@@ -728,6 +728,20 @@ void BestEncInfoCache::destroy()
 
   delete[] m_pCoeff;
   delete[] m_pPcmBuf;
+
+#if JVET_O0119_BASE_PALETTE_444
+  if (m_runType != nullptr)
+  {
+    delete[] m_runType;
+    m_runType = nullptr;
+  }
+  if (m_runLength != nullptr)
+  {
+    delete[] m_runLength;
+    m_runLength = nullptr;
+  }
+#endif
+
 }
 
 void BestEncInfoCache::init( const Slice &slice )
diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp
index 8e2d3d318a4b6020ba86ce59a3b8b7feb56a2087..0b8bc656effdad16943aef80f23faeff915a3721 100644
--- a/source/Lib/EncoderLib/InterSearch.cpp
+++ b/source/Lib/EncoderLib/InterSearch.cpp
@@ -2508,7 +2508,7 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner)
         )
       {
         bool doBiPred = true;
-		tryBipred = 1;
+        tryBipred = 1;
         cMvBi[0] = cMv[0];
         cMvBi[1] = cMv[1];
         iRefIdxBi[0] = iRefIdx[0];
@@ -2749,7 +2749,7 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner)
           {
             if (mvPrecAdj && pu.cu->imv)
             {
-              mvCand.roundIbcPrecInternal2Amvr(pu.cu->imv);
+              mvCand.roundTransPrecInternal2Amvr(pu.cu->imv);
             }
 
             bool toAddMvCand = true;
@@ -2877,19 +2877,19 @@ void InterSearch::predInterSearch(CodingUnit& cu, Partitioner& partitioner)
     iRefIdx[1] = refIdxValidList1;
     uiBits [1] = bitsValidList1;
     uiCost [1] = costValidList1;
-	if (cu.cs->pps->getWPBiPred() == true && tryBipred && (gbiIdx != GBI_DEFAULT))
-	{
-		CHECK(iRefIdxBi[0]<0, "Invalid picture reference index");
-		CHECK(iRefIdxBi[1]<0, "Invalid picture reference index");
-		cu.cs->slice->getWpScaling(REF_PIC_LIST_0, iRefIdxBi[0], wp0);
-		cu.cs->slice->getWpScaling(REF_PIC_LIST_1, iRefIdxBi[1], wp1);
-		if ((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag
-			|| wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag))
-		{
-			uiCostBi = MAX_UINT;
-			enforceGBiPred = false;
-		}
-	}
+    if (cu.cs->pps->getWPBiPred() == true && tryBipred && (gbiIdx != GBI_DEFAULT))
+    {
+      CHECK(iRefIdxBi[0]<0, "Invalid picture reference index");
+      CHECK(iRefIdxBi[1]<0, "Invalid picture reference index");
+      cu.cs->slice->getWpScaling(REF_PIC_LIST_0, iRefIdxBi[0], wp0);
+      cu.cs->slice->getWpScaling(REF_PIC_LIST_1, iRefIdxBi[1], wp1);
+      if ((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag
+        || wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag))
+      {
+        uiCostBi = MAX_UINT;
+        enforceGBiPred = false;
+      }
+    }
     if( enforceGBiPred )
     {
       uiCost[0] = uiCost[1] = MAX_UINT;
@@ -5001,7 +5001,7 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit&       pu,
   // Bi-directional prediction
   if ( slice.isInterB() && !PU::isBipredRestriction(pu) )
   {
-	  tryBipred = 1;
+    tryBipred = 1;
     pu.interDir = 3;
 #if JVET_O0070_PROF
     m_isBi = true;
@@ -5235,16 +5235,16 @@ void InterSearch::xPredAffineInterSearch( PredictionUnit&       pu,
   uiCost[1]  = costValidList1;
   if (pu.cs->pps->getWPBiPred() == true && tryBipred && (gbiIdx != GBI_DEFAULT))
   {
-	  CHECK(iRefIdxBi[0]<0, "Invalid picture reference index");
-	  CHECK(iRefIdxBi[1]<0, "Invalid picture reference index");
-	  pu.cs->slice->getWpScaling(REF_PIC_LIST_0, iRefIdxBi[0], wp0);
-	  pu.cs->slice->getWpScaling(REF_PIC_LIST_1, iRefIdxBi[1], wp1);
-	  if ((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag
-		  || wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag))
-	  {
-		  uiCostBi = MAX_UINT;
-		  enforceGBiPred = false;
-	  }
+    CHECK(iRefIdxBi[0]<0, "Invalid picture reference index");
+    CHECK(iRefIdxBi[1]<0, "Invalid picture reference index");
+    pu.cs->slice->getWpScaling(REF_PIC_LIST_0, iRefIdxBi[0], wp0);
+    pu.cs->slice->getWpScaling(REF_PIC_LIST_1, iRefIdxBi[1], wp1);
+    if ((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag
+      || wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag))
+    {
+      uiCostBi = MAX_UINT;
+      enforceGBiPred = false;
+    }
   }
   if( enforceGBiPred )
   {
@@ -8169,4 +8169,4 @@ bool InterSearch::searchBv(PredictionUnit& pu, int xPos, int yPos, int width, in
 }
 #endif
 
-//! \}
\ No newline at end of file
+//! \}
diff --git a/source/Lib/EncoderLib/NALwrite.cpp b/source/Lib/EncoderLib/NALwrite.cpp
index de6de5bb963fe1807cf7f011cba9bbfbf90cb08a..35ffc4d5fdb20d7d132a3a4f7f7a16b172974853 100644
--- a/source/Lib/EncoderLib/NALwrite.cpp
+++ b/source/Lib/EncoderLib/NALwrite.cpp
@@ -53,7 +53,7 @@ OutputBitstream bsNALUHeader;
   if((nalu.m_nalUnitType >= 16) && (nalu.m_nalUnitType <= 31)) {
     zeroTidRequiredFlag = 1;
   }
-  bsNALUHeader.write(zeroTidRequiredFlag, 1);    		    // zero_tid_required_flag
+  bsNALUHeader.write(zeroTidRequiredFlag, 1);           // zero_tid_required_flag
   bsNALUHeader.write(nalu.m_temporalId+1, 3);           // nuh_temporal_id_plus1
   uint32_t nalUnitTypeLsb = (nalu.m_nalUnitType) - (zeroTidRequiredFlag << 4);
   bsNALUHeader.write(nalUnitTypeLsb, 4);                // nal_unit_type_lsb
diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp
index 90f9f3345bbb1413e20e4539484c82c6bdb6bd0e..04d2abe1d585e60ca5e049af367c9f4af7be1bfb 100644
--- a/source/Lib/EncoderLib/VLCWriter.cpp
+++ b/source/Lib/EncoderLib/VLCWriter.cpp
@@ -327,8 +327,8 @@ void HLSWriter::codePPS( const PPS* pcPPS )
   }
   else
   {
-	// make sure single brick per slice is set by encoder such that the behaviour is same as for setting it to true
-	CHECK(pcPPS->getSingleBrickPerSliceFlag() != true, "SingleBrickPerSliceFlag must be set to 1 when not present");
+    // make sure single brick per slice is set by encoder such that the behaviour is same as for setting it to true
+    CHECK(pcPPS->getSingleBrickPerSliceFlag() != true, "SingleBrickPerSliceFlag must be set to 1 when not present");
     // make sure rect_slice_flag is set
     CHECK (pcPPS->getRectSliceFlag()!=true, "RectSliceFlag must be equalt to 1 for single_tile_in_pic_flag equal to 1");
   }