diff --git a/source/App/BitstreamExtractorApp/BitstreamExtractorAppCfg.cpp b/source/App/BitstreamExtractorApp/BitstreamExtractorAppCfg.cpp
index d992adb88c0e6559569c671ee79a8a52364bbefa..586ee2d1cd424997dc3b11069ab6c2306360bd35 100644
--- a/source/App/BitstreamExtractorApp/BitstreamExtractorAppCfg.cpp
+++ b/source/App/BitstreamExtractorApp/BitstreamExtractorAppCfg.cpp
@@ -42,7 +42,6 @@
 #include "CommonLib/dtrace_next.h"
 #endif
 
-using namespace std;
 namespace po = df::program_options_lite;
 
 
@@ -65,37 +64,39 @@ namespace po = df::program_options_lite;
   int  verbosity;
 
   po::Options opts;
-  opts.addOptions()
 
+  // clang-format off
+  opts.addOptions()
   ("help",                      printHelp,                             false,      "This help text")
-  ("BitstreamFileIn,b",         m_bitstreamFileNameIn,                 string(""), "Bitstream input file name")
-  ("BitstreamFileOut,o",        m_bitstreamFileNameOut,                string(""), "bitstream output file name")
+  ("BitstreamFileIn,b",         m_bitstreamFileNameIn,                 std::string(""), "Bitstream input file name")
+  ("BitstreamFileOut,o",        m_bitstreamFileNameOut,                std::string(""), "bitstream output file name")
   ("MaxTemporalLayer,t",        m_maxTemporalLayer,                    -1,         "Maximum Temporal Layer to be decoded. -1 to decode all layers")
   ("TargetOutputLayerSet,p",    m_targetOlsIdx,                        -1,         "Target output layer set index")
   ("SubPicIdx,s",               m_subPicIdx,                           -1,         "Target subpic index for target output layers that containing multiple subpictures. -1 to decode all subpictures")
 
 #if ENABLE_TRACING
   ("TraceChannelsList",         printTracingChannelsList,              false,        "List all available tracing channels" )
-  ("TraceRule",                 tracingRule,                           string( "" ), "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")" )
-  ("TraceFile",                 tracingFile,                           string( "" ), "Tracing file" )
+  ("TraceRule",                 tracingRule,                           std::string( "" ), "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")" )
+  ("TraceFile",                 tracingFile,                           std::string( "" ), "Tracing file" )
 #endif
 
   ("Verbosity,v",               verbosity,                             (int)VERBOSE, "Specifies the level of the verboseness")
   ("WarnUnknowParameter,w",     warnUnknownParameter,                  false,        "Warn for unknown configuration parameters instead of failing")
   ;
+  // clang-format on
 
   po::setDefaults(opts);
   po::ErrorReporter err;
-  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv, err);
+  const std::list<const char *> &argv_unhandled = po::scanArgv(opts, argc, (const char **) argv, err);
 
-  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+  for (std::list<const char *>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
     std::cerr << "Unhandled argument ignored: "<< *it << std::endl;
   }
 
   if (argc == 1 || printHelp)
   {
-    po::doHelp(cout, opts);
+    po::doHelp(std::cout, opts);
     return false;
   }
 
diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp
index dfae420c6b28da87c29c45940f17e0099905b80c..3ea81c400157f3616ce7e9f577a0ed5a29eec85a 100644
--- a/source/App/DecoderApp/DecApp.cpp
+++ b/source/App/DecoderApp/DecApp.cpp
@@ -48,8 +48,6 @@
 #endif
 #include "CommonLib/dtrace_codingstruct.h"
 
-using namespace std;
-
 //! \ingroup DecoderApp
 //! \{
 
@@ -93,15 +91,15 @@ uint32_t DecApp::decode()
 #if GREEN_METADATA_SEI_ENABLED
   FeatureCounterStruct featureCounter;
   FeatureCounterStruct featureCounterOld;
-  ifstream bitstreamSize(m_bitstreamFileName.c_str(), ifstream::in | ifstream::binary);
+  std::ifstream        bitstreamSize(m_bitstreamFileName.c_str(), std::ifstream::in | std::ifstream::binary);
   std::streampos fsize = 0;
   fsize = bitstreamSize.tellg();
   bitstreamSize.seekg( 0, std::ios::end );
   featureCounter.bytes = (int) bitstreamSize.tellg() - (int) fsize;
   bitstreamSize.close();
 #endif
-  
-  ifstream bitstreamFile(m_bitstreamFileName.c_str(), ifstream::in | ifstream::binary);
+
+  std::ifstream bitstreamFile(m_bitstreamFileName.c_str(), std::ifstream::in | std::ifstream::binary);
   if (!bitstreamFile)
   {
     EXIT( "Failed to open bitstream file " << m_bitstreamFileName.c_str() << " for reading" ) ;
@@ -449,7 +447,7 @@ uint32_t DecApp::decode()
           {
             size_t      pos         = reconFileName.find_last_of('.');
             std::string layerString = std::string(".layer") + std::to_string(nalu.m_nuhLayerId);
-            if (pos != string::npos)
+            if (pos != std::string::npos)
             {
               reconFileName.insert(pos, layerString);
             }
@@ -480,7 +478,7 @@ uint32_t DecApp::decode()
                 }
                 frameRate  = hrd->getTimeScale() * elementDurationInTc;
                 frameScale = hrd->getNumUnitsInTick();
-                int gcd    = calcGcd(max(frameRate, frameScale), min(frameRate, frameScale));
+                int gcd    = calcGcd(std::max(frameRate, frameScale), std::min(frameRate, frameScale));
                 frameRate /= gcd;
                 frameScale /= gcd;
               }
@@ -521,7 +519,7 @@ uint32_t DecApp::decode()
           {
             size_t      pos         = SEIFGSFileName.find_last_of('.');
             std::string layerString = std::string(".layer") + std::to_string(nalu.m_nuhLayerId);
-            if (pos != string::npos)
+            if (pos != std::string::npos)
             {
               SEIFGSFileName.insert(pos, layerString);
             }
@@ -557,7 +555,7 @@ uint32_t DecApp::decode()
           if (m_SEICTIFileName.compare("/dev/null") && m_cDecLib.getVPS() != nullptr && m_cDecLib.getVPS()->getMaxLayers() > 1 && xIsNaluWithinTargetOutputLayerIdSet(&nalu))
           {
             size_t pos = SEICTIFileName.find_last_of('.');
-            if (pos != string::npos)
+            if (pos != std::string::npos)
             {
               SEICTIFileName.insert(pos, std::to_string(nalu.m_nuhLayerId));
             }
@@ -617,7 +615,7 @@ uint32_t DecApp::decode()
             }
 
             uint32_t tmpInfo = (uint32_t)(m_activeSiiInfo.size() + 1);
-            m_activeSiiInfo.insert(pair<uint32_t, IdrSiiInfo>(tmpInfo, curSII));
+            m_activeSiiInfo.insert(std::pair<uint32_t, IdrSiiInfo>(tmpInfo, curSII));
             curSIIInfo = seiShutterIntervalInfo;
           }
           else
@@ -625,7 +623,7 @@ uint32_t DecApp::decode()
             curSII.m_isValidSii = false;
             hasValidSII         = false;
             uint32_t tmpInfo = (uint32_t)(m_activeSiiInfo.size() + 1);
-            m_activeSiiInfo.insert(pair<uint32_t, IdrSiiInfo>(tmpInfo, curSII));
+            m_activeSiiInfo.insert(std::pair<uint32_t, IdrSiiInfo>(tmpInfo, curSII));
           }
         }
         else
diff --git a/source/App/DecoderApp/DecAppCfg.cpp b/source/App/DecoderApp/DecAppCfg.cpp
index fb871c50736c0a1ef859479bf7723b003695bcbb..c679504eafdd0958ef25a934a7b2af0aa00dba14 100644
--- a/source/App/DecoderApp/DecAppCfg.cpp
+++ b/source/App/DecoderApp/DecAppCfg.cpp
@@ -44,7 +44,6 @@
 #include "CommonLib/ChromaFormat.h"
 #include "CommonLib/dtrace_next.h"
 
-using namespace std;
 namespace po = df::program_options_lite;
 
 //! \ingroup DecoderApp
@@ -60,61 +59,61 @@ namespace po = df::program_options_lite;
 bool DecAppCfg::parseCfg( int argc, char* argv[] )
 {
   bool do_help = false;
-  string cfg_TargetDecLayerIdSetFile;
-  string outputColourSpaceConvert;
+  std::string cfg_TargetDecLayerIdSetFile;
+  std::string outputColourSpaceConvert;
   int warnUnknowParameter = 0;
 #if ENABLE_TRACING
-  string sTracingRule;
-  string sTracingFile;
+  std::string sTracingRule;
+  std::string sTracingFile;
   bool   bTracingChannelsList = false;
 #endif
 #if ENABLE_SIMD_OPT
   std::string ignore;
 #endif
   po::Options opts;
+
   // clang-format off
   opts.addOptions()
-
   ("help",                      do_help,                               false,      "this help text")
-  ("BitstreamFile,b",           m_bitstreamFileName,                   string(""), "bitstream input file name")
-  ("ReconFile,o",               m_reconFileName,                       string(""), "reconstructed YUV output file name\n")
-  ("OplFile,-opl",              m_oplFilename,                         string(""), "opl-file name without extension for conformance testing\n")
+  ("BitstreamFile,b",           m_bitstreamFileName,                   std::string(""), "bitstream input file name")
+  ("ReconFile,o",               m_reconFileName,                       std::string(""), "reconstructed YUV output file name\n")
+  ("OplFile,-opl",              m_oplFilename,                         std::string(""), "opl-file name without extension for conformance testing\n")
 
 #if ENABLE_SIMD_OPT
-  ("SIMD",                      ignore,                                string(""), "SIMD extension to use (SCALAR, SSE41, SSE42, AVX, AVX2, AVX512), default: the highest supported extension\n")
+  ("SIMD",                      ignore,                                std::string(""), "SIMD extension to use (SCALAR, SSE41, SSE42, AVX, AVX2, AVX512), default: the highest supported extension\n")
 #endif
   ("WarnUnknowParameter,w",     warnUnknowParameter,                   0,          "warn for unknown configuration parameters instead of failing")
   ("SkipFrames,s",              m_iSkipFrame,                          0,          "number of frames to skip before random access")
   ("OutputBitDepth,d",          m_outputBitDepth[ChannelType::LUMA],   0,          "bit depth of YUV output luma component (default: use 0 for native depth)")
   ("OutputBitDepthC,d",         m_outputBitDepth[ChannelType::CHROMA], 0,          "bit depth of YUV output chroma component (default: use luma output bit-depth)")
-  ("OutputColourSpaceConvert",  outputColourSpaceConvert,              string(""), "Colour space conversion to apply to input 444 video. Permitted values are (empty string=UNCHANGED) " + getListOfColourSpaceConverts(false))
+  ("OutputColourSpaceConvert",  outputColourSpaceConvert,              std::string(""), "Colour space conversion to apply to input 444 video. Permitted values are (empty string=UNCHANGED) " + getListOfColourSpaceConverts(false))
   ("MaxTemporalLayer,t",        m_iMaxTemporalLayer,                   500,        "Maximum Temporal Layer to be decoded. -1 to decode all layers")
   ("TargetOutputLayerSet,p",    m_targetOlsIdx,                        500,        "Target output layer set index")
 #if JVET_Z0120_SII_SEI_PROCESSING
-  ("SEIShutterIntervalPostFilename,-sii", m_shutterIntervalPostFileName, string(""), "Post Filtering with Shutter Interval SEI. If empty, no filtering is applied (ignore SEI message)\n")
+  ("SEIShutterIntervalPostFilename,-sii", m_shutterIntervalPostFileName, std::string(""), "Post Filtering with Shutter Interval SEI. If empty, no filtering is applied (ignore SEI message)\n")
 #endif
   ("SEIDecodedPictureHash,-dph", m_decodedPictureHashSEIEnabled,       1,          "Control handling of decoded picture hash SEI messages\n"
                                                                                    "\t1: check hash in SEI messages if available in the bitstream\n"
                                                                                    "\t0: ignore SEI message")
   ("SEINoDisplay",              m_decodedNoDisplaySEIEnabled,          true,       "Control handling of decoded no display SEI messages")
-  ("TarDecLayerIdSetFile,l",    cfg_TargetDecLayerIdSetFile,           string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
-  ("SEIColourRemappingInfoFilename", m_colourRemapSEIFileName,         string(""), "Colour Remapping YUV output file name. If empty, no remapping is applied (ignore SEI message)\n")
-  ("SEICTIFilename",            m_SEICTIFileName,                      string(""), "CTI YUV output file name. If empty, no Colour Transform is applied (ignore SEI message)\n")
-  ("SEIFGSFilename",            m_SEIFGSFileName,                      string(""), "FGS YUV output file name. If empty, no film grain is applied (ignore SEI message)\n")
-  ("SEIAnnotatedRegionsInfoFilename", m_annotatedRegionsSEIFileName,   string(""), "Annotated regions output file name. If empty, no object information will be saved (ignore SEI message)\n")
-  ("OutputDecodedSEIMessagesFilename", m_outputDecodedSEIMessagesFilename, string(""), "When non empty, output decoded SEI messages to the indicated file. If file is '-', then output to stdout\n")
+  ("TarDecLayerIdSetFile,l",    cfg_TargetDecLayerIdSetFile,           std::string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
+  ("SEIColourRemappingInfoFilename", m_colourRemapSEIFileName,         std::string(""), "Colour Remapping YUV output file name. If empty, no remapping is applied (ignore SEI message)\n")
+  ("SEICTIFilename",            m_SEICTIFileName,                      std::string(""), "CTI YUV output file name. If empty, no Colour Transform is applied (ignore SEI message)\n")
+  ("SEIFGSFilename",            m_SEIFGSFileName,                      std::string(""), "FGS YUV output file name. If empty, no film grain is applied (ignore SEI message)\n")
+  ("SEIAnnotatedRegionsInfoFilename", m_annotatedRegionsSEIFileName,   std::string(""), "Annotated regions output file name. If empty, no object information will be saved (ignore SEI message)\n")
+  ("OutputDecodedSEIMessagesFilename", m_outputDecodedSEIMessagesFilename, std::string(""), "When non empty, output decoded SEI messages to the indicated file. If file is '-', then output to stdout\n")
 #if JVET_S0257_DUMP_360SEI_MESSAGE
-  ("360DumpFile",               m_outputDecoded360SEIMessagesFilename, string(""), "When non empty, output decoded 360 SEI messages to the indicated file.\n")
+  ("360DumpFile",               m_outputDecoded360SEIMessagesFilename, std::string(""), "When non empty, output decoded 360 SEI messages to the indicated file.\n")
 #endif
   ("ClipOutputVideoToRec709Range",      m_clipOutputVideoToRec709Range,  false,   "If true then clip output video to the Rec. 709 Range on saving")
   ("PYUV",                      m_packedYUVMode,                       false,      "If true then output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data. Ignored for interlaced output.")
 #if ENABLE_TRACING
   ("TraceChannelsList",         bTracingChannelsList,                  false,      "List all available tracing channels")
-  ("TraceRule",                 sTracingRule,                          string(""), "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")")
-  ("TraceFile",                 sTracingFile,                          string(""), "Tracing file")
+  ("TraceRule",                 sTracingRule,                          std::string(""), "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")")
+  ("TraceFile",                 sTracingFile,                          std::string(""), "Tracing file")
 #endif
 #if JVET_J0090_MEMORY_BANDWITH_MEASURE
-  ("CacheCfg",                  m_cacheCfgFile,                        string(""), "CacheCfg File")
+  ("CacheCfg",                  m_cacheCfgFile,                        std::string(""), "CacheCfg File")
 #endif
 #if RExt__DECODER_DEBUG_STATISTICS
   ("Stats",                     m_statMode,                            3,          "Control decoder debugging statistic output mode\n"
@@ -125,7 +124,7 @@ bool DecAppCfg::parseCfg( int argc, char* argv[] )
 #endif
 #if GREEN_METADATA_SEI_ENABLED
   ("GMFA", m_GMFA, false, "Write output file for the Green-Metadata analyzer for decoder complexity metrics (JVET-P0085)\n")
-  ("GMFAFile", m_GMFAFile, string(""), "File for the Green Metadata Bit Stream Feature Analyzer output (JVET-P0085)\n")
+  ("GMFAFile", m_GMFAFile, std::string(""), "File for the Green Metadata Bit Stream Feature Analyzer output (JVET-P0085)\n")
   ("GMFAFramewise", m_GMFAFramewise, false, "Output of frame-wise Green Metadata Bit Stream Feature Analyzer files\n")
 #endif
   ("MCTSCheck",                m_mctsCheck,                           false,       "If enabled, the decoder checks for violations of mc_exact_sample_value_match_flag in Temporal MCTS ")
@@ -140,16 +139,16 @@ bool DecAppCfg::parseCfg( int argc, char* argv[] )
 
   po::setDefaults(opts);
   po::ErrorReporter err;
-  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv, err);
+  const std::list<const char *> &argv_unhandled = po::scanArgv(opts, argc, (const char **) argv, err);
 
-  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+  for (std::list<const char *>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
     msg( ERROR, "Unhandled argument ignored: `%s'\n", *it);
   }
 
   if (argc == 1 || do_help)
   {
-    po::doHelp(cout, opts);
+    po::doHelp(std::cout, opts);
     return false;
   }
 
diff --git a/source/App/DecoderApp/decmain.cpp b/source/App/DecoderApp/decmain.cpp
index a967625ee590e91eaf76d34d7cb88b1d8234cdd7..bc765bbd92c8be277d14cb365f989759762db948 100644
--- a/source/App/DecoderApp/decmain.cpp
+++ b/source/App/DecoderApp/decmain.cpp
@@ -41,8 +41,6 @@
 #include "DecApp.h"
 #include "program_options_lite.h"
 
-using namespace std;
-
 //! \ingroup DecoderApp
 //! \{
 
@@ -63,7 +61,7 @@ int main(int argc, char* argv[])
 #if ENABLE_SIMD_OPT
   std::string SIMD;
   df::program_options_lite::Options optsSimd;
-  optsSimd.addOptions()( "SIMD", SIMD, string( "" ), "" );
+  optsSimd.addOptions()("SIMD", SIMD, std::string(""), "");
   df::program_options_lite::SilentReporter err;
   df::program_options_lite::scanArgv( optsSimd, argc, ( const char** ) argv, err );
   fprintf( stdout, "[SIMD=%s] ", read_x86_extension( SIMD ) );
diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp
index eb6a67e77fa99e38c5aa26f4128ad4262455e963..6f161224a981a35cd21cb1c70fa3d17c231c3efc 100644
--- a/source/App/EncoderApp/EncApp.cpp
+++ b/source/App/EncoderApp/EncApp.cpp
@@ -46,8 +46,6 @@
 #include "EncoderLib/AnnexBwrite.h"
 #include "EncoderLib/EncLibCommon.h"
 
-using namespace std;
-
 //! \ingroup EncoderApp
 //! \{
 
@@ -55,9 +53,7 @@ using namespace std;
 // Constructor / destructor / initialization / destroy
 // ====================================================================================================================
 
-EncApp::EncApp( fstream& bitStream, EncLibCommon* encLibCommon )
-  : m_cEncLib( encLibCommon )
-  , m_bitstream( bitStream )
+EncApp::EncApp(std::fstream &bitStream, EncLibCommon *encLibCommon) : m_cEncLib(encLibCommon), m_bitstream(bitStream)
 {
   m_frameRcvd      = 0;
   m_totalBytes = 0;
@@ -138,7 +134,7 @@ void EncApp::xInitLibCfg( int layerIdx )
       {
         for (int j = 0, k = 0; j < i; j++)
         {
-          if (m_refLayerIdxStr[i].find(to_string(j)) != std::string::npos)
+          if (m_refLayerIdxStr[i].find(std::to_string(j)) != std::string::npos)
           {
             vps.setDirectRefLayerFlag(i, j, true);
             vps.setInterLayerRefIdc( i, j, k );
@@ -149,10 +145,10 @@ void EncApp::xInitLibCfg( int layerIdx )
             vps.setDirectRefLayerFlag(i, j, false);
           }
         }
-        string::size_type beginStr = m_maxTidILRefPicsPlus1Str[i].find_first_not_of(" ", 0);
-        string::size_type endStr = m_maxTidILRefPicsPlus1Str[i].find_first_of(" ", beginStr);
+        std::string::size_type beginStr = m_maxTidILRefPicsPlus1Str[i].find_first_not_of(" ", 0);
+        std::string::size_type endStr   = m_maxTidILRefPicsPlus1Str[i].find_first_of(" ", beginStr);
         int t = 0;
-        while (string::npos != beginStr || string::npos != endStr)
+        while (std::string::npos != beginStr || std::string::npos != endStr)
         {
           m_cfgVPSParameters.m_maxTidILRefPicsPlus1[i][t++] = std::stoi(m_maxTidILRefPicsPlus1Str[i].substr(beginStr, endStr - beginStr));
           beginStr = m_maxTidILRefPicsPlus1Str[i].find_first_not_of(" ", endStr);
@@ -186,7 +182,7 @@ void EncApp::xInitLibCfg( int layerIdx )
         {
           for (int j = 0; j < vps.getMaxLayers(); j++)
           {
-            if (m_olsOutputLayerStr[i].find(to_string(j)) != std::string::npos)
+            if (m_olsOutputLayerStr[i].find(std::to_string(j)) != std::string::npos)
             {
               vps.setOlsOutputLayerFlag(i, j, 1);
             }
@@ -1423,7 +1419,7 @@ void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerId )
     if( m_reconFileName.compare( "/dev/null" ) &&  (m_maxLayers > 1) )
     {
       size_t pos = reconFileName.find_last_of('.');
-      if (pos != string::npos)
+      if (pos != std::string::npos)
       {
         reconFileName.insert( pos, std::to_string( layerId ) );
       }
@@ -1520,7 +1516,7 @@ void EncApp::createLib( const int layerIdx )
 
   if( !m_bitstream.is_open() )
   {
-    m_bitstream.open( m_bitstreamFileName.c_str(), fstream::binary | fstream::out );
+    m_bitstream.open(m_bitstreamFileName.c_str(), std::fstream::binary | std::fstream::out);
     if( !m_bitstream )
     {
       EXIT( "Failed to open bitstream file " << m_bitstreamFileName.c_str() << " for writing\n" );
@@ -1837,7 +1833,7 @@ void EncApp::xWriteOutput(int numEncoded, std::list<PelUnitBuf *> &recBufList)
 
 void EncApp::outputAU( const AccessUnit& au )
 {
-  const vector<uint32_t>& stats = writeAnnexBAccessUnit(m_bitstream, au);
+  const std::vector<uint32_t> &stats = writeAnnexBAccessUnit(m_bitstream, au);
   rateStatsAccum(au, stats);
   m_bitstream.flush();
 }
@@ -1849,7 +1845,7 @@ void EncApp::outputAU( const AccessUnit& au )
 void EncApp::rateStatsAccum(const AccessUnit& au, const std::vector<uint32_t>& annexBsizes)
 {
   AccessUnit::const_iterator it_au = au.begin();
-  vector<uint32_t>::const_iterator it_stats = annexBsizes.begin();
+  std::vector<uint32_t>::const_iterator it_stats = annexBsizes.begin();
 
   for (; it_au != au.end(); it_au++, it_stats++)
   {
diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index bd6524fddd5a9615eddfaa990d3689dbb96ec4b5..97ec702a2fb68d72f05691c240f03d1c592e98e4 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -55,7 +55,6 @@
 #define MACRO_TO_STRING_HELPER(val) #val
 #define MACRO_TO_STRING(val) MACRO_TO_STRING_HELPER(val)
 
-using namespace std;
 namespace po = df::program_options_lite;
 
 enum ExtendedProfileName   // this is used for determining profile strings, where multiple profiles map to a single
@@ -304,10 +303,9 @@ static std::string enumToString(P map[], uint32_t mapLen, const T val)
   return std::string();
 }
 
-template<typename T, typename P>
-static istream& readStrToEnum(P map[], uint32_t mapLen, istream &in, T &val)
+template<typename T, typename P> static std::istream &readStrToEnum(P map[], uint32_t mapLen, std::istream &in, T &val)
 {
-  string str;
+  std::string str;
   in >> str;
 
   for (uint32_t i = 0; i < mapLen; i++)
@@ -319,44 +317,42 @@ static istream& readStrToEnum(P map[], uint32_t mapLen, istream &in, T &val)
     }
   }
   /* not found */
-  in.setstate(ios::failbit);
+  in.setstate(std::ios::failbit);
 found:
   return in;
 }
 
 //inline to prevent compiler warnings for "unused static function"
 
-static inline istream& operator >> (istream &in, ExtendedProfileName &profile)
+static inline std::istream &operator>>(std::istream &in, ExtendedProfileName &profile)
 {
   return readStrToEnum(strToExtendedProfile, sizeof(strToExtendedProfile)/sizeof(*strToExtendedProfile), in, profile);
 }
 
 namespace Level
 {
-  static inline istream& operator >> (istream &in, Tier &tier)
+  static inline std::istream &operator>>(std::istream &in, Tier &tier)
   {
     return readStrToEnum(strToTier, sizeof(strToTier)/sizeof(*strToTier), in, tier);
   }
 
-  static inline istream& operator >> (istream &in, Name &level)
+  static inline std::istream &operator>>(std::istream &in, Name &level)
   {
     return readStrToEnum(strToLevel, sizeof(strToLevel)/sizeof(*strToLevel), in, level);
   }
 }
 
-static inline istream& operator >> (istream &in, CostMode &mode)
+static inline std::istream &operator>>(std::istream &in, CostMode &mode)
 {
   return readStrToEnum(strToCostMode, sizeof(strToCostMode)/sizeof(*strToCostMode), in, mode);
 }
 
-static inline istream& operator >> (istream &in, ScalingListMode &mode)
+static inline std::istream &operator>>(std::istream &in, ScalingListMode &mode)
 {
   return readStrToEnum(strToScalingListMode, sizeof(strToScalingListMode)/sizeof(*strToScalingListMode), in, mode);
 }
 
-
-template <class T>
-static inline istream& operator >> (std::istream &in, SMultiValueInput<T> &values)
+template<class T> static inline std::istream &operator>>(std::istream &in, SMultiValueInput<T> &values)
 {
   return values.readValues(in);
 }
@@ -377,14 +373,15 @@ T SMultiValueInput<T>::readValue(const char *&pStr, bool &bSuccess)
   return val;
 }
 
-template <class T>
-istream& SMultiValueInput<T>::readValues(std::istream &in)
+template<class T> std::istream &SMultiValueInput<T>::readValues(std::istream &in)
 {
   values.clear();
-  string str;
+  std::string str;
   while (!in.eof())
   {
-    string tmp; in >> tmp; str+=" " + tmp;
+    std::string tmp;
+    in >> tmp;
+    str += " " + tmp;
   }
   if (!str.empty())
   {
@@ -398,13 +395,13 @@ istream& SMultiValueInput<T>::readValues(std::istream &in)
       T val=readValue(pStr, bSuccess);
       if (!bSuccess)
       {
-        in.setstate(ios::failbit);
+        in.setstate(std::ios::failbit);
         break;
       }
 
       if (maxNumValuesIncl != 0 && values.size() >= maxNumValuesIncl)
       {
-        in.setstate(ios::failbit);
+        in.setstate(std::ios::failbit);
         break;
       }
       values.push_back(val);
@@ -419,13 +416,12 @@ istream& SMultiValueInput<T>::readValues(std::istream &in)
   }
   if (values.size() < minNumValuesIncl)
   {
-    in.setstate(ios::failbit);
+    in.setstate(std::ios::failbit);
   }
   return in;
 }
 
-template <class T>
-static inline istream& operator >> (std::istream &in, EncAppCfg::OptionalValue<T> &value)
+template<class T> static inline std::istream &operator>>(std::istream &in, EncAppCfg::OptionalValue<T> &value)
 {
   in >> std::ws;
   if (in.eof())
@@ -440,8 +436,7 @@ static inline istream& operator >> (std::istream &in, EncAppCfg::OptionalValue<T
   return in;
 }
 
-template <class T1, class T2>
-static inline istream& operator >> (std::istream& in, std::map<T1, T2>& map)
+template<class T1, class T2> static inline std::istream &operator>>(std::istream &in, std::map<T1, T2> &map)
 {
   T1 key;
   T2 value;
@@ -452,7 +447,7 @@ static inline istream& operator >> (std::istream& in, std::map<T1, T2>& map)
   }
   catch (...)
   {
-    in.setstate(ios::failbit);
+    in.setstate(std::ios::failbit);
   }
 
   map[key] = value;
@@ -576,8 +571,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   int tmpMotionEstimationSearchMethod;
   int tmpDecodedPictureHashSEIMappedType;
   int tmpSubpicDecodedPictureHashMappedType;
-  string inputColourSpaceConvert;
-  string inputPathPrefix;
+  std::string         inputColourSpaceConvert;
+  std::string         inputPathPrefix;
   ExtendedProfileName extendedProfile;
 
   // Multi-value input fields:                                // minval, maxval (incl), min_entries, max_entries (incl) [, default values, number of default values]
@@ -747,8 +742,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   }
 
 #if ENABLE_TRACING
-  string sTracingRule;
-  string sTracingFile;
+  std::string sTracingRule;
+  std::string sTracingFile;
   bool   bTracingChannelsList = false;
 #endif
 #if ENABLE_SIMD_OPT
@@ -765,15 +760,15 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ("WarnUnknowParameter,w",                           warnUnknowParameter,                                  0, "warn for unknown configuration parameters instead of failing")
   ("isSDR",                                           sdr,                                              false, "compatibility")
 #if ENABLE_SIMD_OPT
-  ("SIMD",                                            ignore,                                      string(""), "SIMD extension to use (SCALAR, SSE41, SSE42, AVX, AVX2, AVX512), default: the highest supported extension\n")
+  ("SIMD",                                            ignore,                                      std::string(""), "SIMD extension to use (SCALAR, SSE41, SSE42, AVX, AVX2, AVX512), default: the highest supported extension\n")
 #endif
   // File, I/O and source parameters
-  ("InputFile,i",                                     m_inputFileName,                             string(""), "Original YUV input file name")
-  ("InputPathPrefix,-ipp",                            inputPathPrefix,                             string(""), "pathname to prepend to input filename")
-  ("BitstreamFile,b",                                 m_bitstreamFileName,                         string(""), "Bitstream output file name")
-  ("ReconFile,o",                                     m_reconFileName,                             string(""), "Reconstructed YUV output file name")
+  ("InputFile,i",                                     m_inputFileName,                             std::string(""), "Original YUV input file name")
+  ("InputPathPrefix,-ipp",                            inputPathPrefix,                             std::string(""), "pathname to prepend to input filename")
+  ("BitstreamFile,b",                                 m_bitstreamFileName,                         std::string(""), "Bitstream output file name")
+  ("ReconFile,o",                                     m_reconFileName,                             std::string(""), "Reconstructed YUV output file name")
 #if JVET_Z0120_SII_SEI_PROCESSING
-  ("SEIShutterIntervalPreFilename,-sii",              m_shutterIntervalPreFileName, string(""), "File name of Pre-Filtering video. If empty, not output video\n")
+  ("SEIShutterIntervalPreFilename,-sii",              m_shutterIntervalPreFileName, std::string(""), "File name of Pre-Filtering video. If empty, not output video\n")
 #endif
   ("SourceWidth,-wdt",                                m_sourceWidth,                                       0, "Source picture width")
   ("SourceHeight,-hgt",                               m_sourceHeight,                                      0, "Source picture height")
@@ -788,7 +783,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ("TSRCRicePresent",                                 m_tsrcRicePresentFlag,                            false, "Indicate that TSRC Rice information is present in slice header (not valid in V1 profiles)")
   ("ReverseLastSigCoeff",                             m_reverseLastSigCoeffEnabledFlag,                 false, "enable reverse last significant coefficient postion in RRC (not valid in V1 profiles)")
   ("HighPrecisionPredictionWeighting",                m_highPrecisionOffsetsEnabledFlag,                false, "Use high precision option for weighted prediction (not valid in V1 profiles)")
-  ("InputColourSpaceConvert",                         inputColourSpaceConvert,                     string(""), "Colour space conversion to apply to input video. Permitted values are (empty string=UNCHANGED) " + getListOfColourSpaceConverts(true))
+  ("InputColourSpaceConvert",                         inputColourSpaceConvert,                     std::string(""), "Colour space conversion to apply to input video. Permitted values are (empty string=UNCHANGED) " + getListOfColourSpaceConverts(true))
   ("SNRInternalColourSpace",                          m_snrInternalColourSpace,                         false, "If true, then no colour space conversion is applied prior to SNR, otherwise inverse of input is applied.")
   ("OutputInternalColourSpace",                       m_outputInternalColourSpace,                      false, "If true, then no colour space conversion is applied for reconstructed video, otherwise inverse of input is applied.")
   ("InputChromaFormat",                               tmpInputChromaFormat,                               420, "InputChromaFormatIDC")
@@ -816,8 +811,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ("ClipInputVideoToRec709Range",                     m_clipInputVideoToRec709Range,                   false, "If true then clip input video to the Rec. 709 Range on loading when InternalBitDepth is less than MSBExtendedBitDepth")
   ("ClipOutputVideoToRec709Range",                    m_clipOutputVideoToRec709Range,                  false, "If true then clip output video to the Rec. 709 Range on saving when OutputBitDepth is less than InternalBitDepth")
   ("PYUV",                                            m_packedYUVMode,                                  false, "If true then output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data. Ignored for interlaced output.")
-  ("SummaryOutFilename",                              m_summaryOutFilename,                          string(), "Filename to use for producing summary output file. If empty, do not produce a file.")
-  ("SummaryPicFilenameBase",                          m_summaryPicFilenameBase,                      string(), "Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended. If empty, do not produce a file.")
+  ("SummaryOutFilename",                              m_summaryOutFilename,                          std::string(), "Filename to use for producing summary output file. If empty, do not produce a file.")
+  ("SummaryPicFilenameBase",                          m_summaryPicFilenameBase,                      std::string(), "Base filename to use for producing summary picture output files. The actual filenames used will have I.txt, P.txt and B.txt appended. If empty, do not produce a file.")
   ("SummaryVerboseness",                              m_summaryVerboseness,                                0u, "Specifies the level of the verboseness of the text output")
   ("Verbosity,v",                                     m_verbosity,                               (int)VERBOSE, "Specifies the level of the verboseness")
 
@@ -850,7 +845,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ("SEIXSDMetricTypeWSPSNR",                          m_xsdMetricTypeWSPSNR,                             false, "Set to 'true' if WSSPSNR shall be signalled. ")
   ("SEIGreenMetadataExtendedRepresentation",          m_greenMetadataExtendedRepresentation,                 0, "Specifies whether reduced or extended set of complexity metrics is signelled. ")
   ("GMFA",                                            m_GMFA,                                            false, "Write output file for the Green-Metadata analyzer for decoder complexity metrics (JVET-P0085)\n")
-  ("GMFAFile",                                        m_GMFAFile,                                   string(""), "File for the Green Metadata Bit Stream Feature Analyzer output (JVET-P0085)\n")
+  ("GMFAFile",                                        m_GMFAFile,                                   std::string(""), "File for the Green Metadata Bit Stream Feature Analyzer output (JVET-P0085)\n")
 #endif
   //Field coding parameters
   ("FieldCoding",                                     m_isField,                                        false, "Signals if it's a field based coding")
@@ -1189,7 +1184,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ("PerceptQPA,-qpa",                                 m_bUsePerceptQPA,                                 false, "perceptually motivated input-adaptive QP modification (default: 0 = off, ignored if -aq is set)")
   ("WPSNR,-wpsnr",                                    m_bUseWPSNR,                                      false, "output perceptually weighted peak SNR (WPSNR) instead of PSNR")
 #endif
-  ("dQPFile,m",                                       m_dQPFileName,                               string(""), "dQP file name")
+  ("dQPFile,m",                                       m_dQPFileName,                               std::string(""), "dQP file name")
   ("RDOQ",                                            m_useRDOQ,                                         true)
   ("RDOQTS",                                          m_useRDOQTS,                                       true)
   ("SelectiveRDOQ",                                   m_useSelectiveRDOQ,                               false, "Enable selective RDOQ")
@@ -1248,7 +1243,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ("WaveFrontSynchro",                                m_entropyCodingSyncEnabledFlag,                   false, "0: entropy coding sync disabled; 1 entropy coding sync enabled")
   ("EntryPointsPresent",                              m_entryPointPresentFlag,                           true, "0: entry points is not present; 1 entry points may be present in slice header")
   ("ScalingList",                                     m_useScalingListId,                    SCALING_LIST_OFF, "0/off: no scaling list, 1/default: default scaling lists, 2/file: scaling lists specified in ScalingListFile")
-  ("ScalingListFile",                                 m_scalingListFileName,                       string(""), "Scaling list file name. Use an empty string to produce help.")
+  ("ScalingListFile",                                 m_scalingListFileName,                       std::string(""), "Scaling list file name. Use an empty string to produce help.")
   ("DisableScalingMatrixForLFNST",                    m_disableScalingMatrixForLfnstBlks,                true, "Disable scaling matrices, when enabled, for LFNST-coded blocks")
   ("DisableScalingMatrixForAlternativeColourSpace",   m_disableScalingMatrixForAlternativeColourSpace,  false, "Disable scaling matrices when the colour space is not equal to the designated colour space of scaling matrix")
   ("ScalingMatrixDesignatedColourSpace",              m_scalingMatrixDesignatedColourSpace,              true, "Indicates if the designated colour space of scaling matrices is equal to the original colour space")
@@ -1412,7 +1407,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 ("SEISubpicLevelInfoRefLevels", cfg_sliRefLevels, cfg_sliRefLevels, "List of reference levels for Subpicture Level Information SEI messages")
 ("SEISubpicLevelInfoExplicitFraction", m_cfgSubpictureLevelInfoSEI.m_explicitFraction, false, "Enable sending of explicit fractions in Subpicture Level Information SEI messages")
 ("SEISubpicLevelInfoNumSubpics", m_cfgSubpictureLevelInfoSEI.m_numSubpictures, 1, "Number of subpictures for Subpicture Level Information SEI messages")
-("SEIAnnotatedRegionsFileRoot,-ar", m_arSEIFileRoot, string(""), "Annotated region SEI parameters root file name (wo num ext); only the file name base is to be added. Underscore and POC would be automatically addded to . E.g. \"-ar ar\" will search for files ar_0.txt, ar_1.txt, ...")
+("SEIAnnotatedRegionsFileRoot,-ar", m_arSEIFileRoot, std::string(""), "Annotated region SEI parameters root file name (wo num ext); only the file name base is to be added. Underscore and POC would be automatically addded to . E.g. \"-ar ar\" will search for files ar_0.txt, ar_1.txt, ...")
 ("SEISubpicLevelInfoMaxSublayers", m_cfgSubpictureLevelInfoSEI.m_sliMaxSublayers, 1, "Number of sublayers for Subpicture Level Information SEI messages")
 ("SEISubpicLevelInfoSublayerInfoPresentFlag", m_cfgSubpictureLevelInfoSEI.m_sliSublayerInfoPresentFlag, false, "Enable sending of level information for all sublayers in Subpicture Level Information SEI messages")
 ("SEISubpicLevelInfoRefLevelFractions", cfg_sliFractions, cfg_sliFractions, "List of subpicture level fractions for Subpicture Level Information SEI messages")
@@ -1440,8 +1435,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 
 #if ENABLE_TRACING
 ("TraceChannelsList", bTracingChannelsList, false, "List all available tracing channels")
-("TraceRule", sTracingRule, string(""), "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")")
-("TraceFile", sTracingFile, string(""), "Tracing file")
+("TraceRule", sTracingRule, std::string(""), "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")")
+("TraceFile", sTracingFile, std::string(""), "Tracing file")
 #endif
 // film grain characteristics SEI
   ("SEIFGCEnabled",                                   m_fgcSEIEnabled,                                   false, "Control generation of the film grain characteristics SEI message")
@@ -1455,8 +1450,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ("SEIFGCCompModelPresentComp1",                     m_fgcSEICompModelPresent[1],                       false, "Specifies the presence of film grain modelling on colour component 1.")
   ("SEIFGCCompModelPresentComp2",                     m_fgcSEICompModelPresent[2],                       false, "Specifies the presence of film grain modelling on colour component 2.")
   ("SEIFGCAnalysisEnabled",                           m_fgcSEIAnalysisEnabled,                           false, "Control adaptive film grain parameter estimation - film grain analysis")
-  ("SEIFGCExternalMask",                              m_fgcSEIExternalMask,                       string( "" ), "Read external file with mask for film grain analysis. If empty string, use internally calculated mask.")
-  ("SEIFGCExternalDenoised",                          m_fgcSEIExternalDenoised,                   string( "" ), "Read external file with denoised sequence for film grain analysis. If empty string, use MCTF for denoising.")
+  ("SEIFGCExternalMask",                              m_fgcSEIExternalMask,                       std::string( "" ), "Read external file with mask for film grain analysis. If empty string, use internally calculated mask.")
+  ("SEIFGCExternalDenoised",                          m_fgcSEIExternalDenoised,                   std::string( "" ), "Read external file with denoised sequence for film grain analysis. If empty string, use MCTF for denoising.")
   ("SEIFGCTemporalFilterPastRefs",                    m_fgcSEITemporalFilterPastRefs,          TF_DEFAULT_REFS, "Number of past references for temporal prefilter")
   ("SEIFGCTemporalFilterFutureRefs",                  m_fgcSEITemporalFilterFutureRefs,        TF_DEFAULT_REFS, "Number of future references for temporal prefilter")
   ("SEIFGCTemporalFilterStrengthFrame*",              m_fgcSEITemporalFilterStrengths, std::map<int, double>(), "Strength for every * frame in FGC-specific temporal filter, where * is an integer.")
@@ -1606,10 +1601,10 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   //SEI prefix indication
   ("SEISEIPrefixIndicationEnabled",                   m_SEIPrefixIndicationSEIEnabled,                   false, "Controls if SEI Prefix Indications SEI messages enabled")
 
-  ("DebugBitstream",                                  m_decodeBitstreams[0],             string( "" ), "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." )
+  ("DebugBitstream",                                  m_decodeBitstreams[0],             std::string( "" ), "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." )
   ("DebugPOC",                                        m_switchPOC,                                 -1, "If DebugBitstream is present, load frames up to this POC from this bitstream. Starting with DebugPOC, return to normal encoding." )
-  ("DecodeBitstream1",                                m_decodeBitstreams[0],             string( "" ), "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." )
-  ("DecodeBitstream2",                                m_decodeBitstreams[1],             string( "" ), "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." )
+  ("DecodeBitstream1",                                m_decodeBitstreams[0],             std::string( "" ), "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." )
+  ("DecodeBitstream2",                                m_decodeBitstreams[1],             std::string( "" ), "Assume the frames up to POC DebugPOC will be the same as in this bitstream. Load those frames from the bitstream instead of encoding them." )
   ("SwitchPOC",                                       m_switchPOC,                                 -1, "If DebugBitstream is present, load frames up to this POC from this bitstream. Starting with DebugPOC, return to normal encoding." )
   ("SwitchDQP",                                       m_switchDQP,                                  0, "delta QP applied to picture with switchPOC and subsequent pictures." )
   ("FastForwardToPOC",                                m_fastForwardToPOC,                          -1, "Get to encoding the specified POC as soon as possible by skipping temporal layers irrelevant for the specified POC." )
@@ -1663,18 +1658,18 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   ( "MaxSublayers",                                   m_maxSublayers,                               7, "Max number of Sublayers")
   ( "DefaultPtlDpbHrdMaxTidFlag",                     m_defaultPtlDpbHrdMaxTidFlag,              true, "specifies that the syntax elements vps_ptl_max_tid[ i ], vps_dpb_max_tid[ i ], and vps_hrd_max_tid[ i ] are not present and are inferred to be equal to the default value vps_max_sublayers_minus1")
   ( "AllIndependentLayersFlag",                       m_allIndependentLayersFlag,                true, "All layers are independent layer")
-  ("AllowablePredDirection",                          m_predDirectionArray, string(""),                "prediction directions allowed for i-th temporal layer")
+  ("AllowablePredDirection",                          m_predDirectionArray, std::string(""),                "prediction directions allowed for i-th temporal layer")
   ( "LayerId%d",                                      m_layerId,                    0, MAX_VPS_LAYERS, "Layer ID")
   ( "NumRefLayers%d",                                 m_numRefLayers,               0, MAX_VPS_LAYERS, "Number of direct reference layer index of i-th layer")
-  ( "RefLayerIdx%d",                                  m_refLayerIdxStr,    string(""), MAX_VPS_LAYERS, "Reference layer index(es)")
+  ( "RefLayerIdx%d",                                  m_refLayerIdxStr,    std::string(""), MAX_VPS_LAYERS, "Reference layer index(es)")
   ( "EachLayerIsAnOlsFlag",                           m_eachLayerIsAnOlsFlag,                    true, "Each layer is an OLS layer flag")
   ( "OlsModeIdc",                                     m_olsModeIdc,                                 0, "Output layer set mode")
   ( "NumOutputLayerSets",                             m_numOutputLayerSets,                         1, "Number of output layer sets")
-  ( "OlsOutputLayer%d",                               m_olsOutputLayerStr, string(""), MAX_VPS_LAYERS, "Output layer index of i-th OLS")
+  ( "OlsOutputLayer%d",                               m_olsOutputLayerStr, std::string(""), MAX_VPS_LAYERS, "Output layer index of i-th OLS")
   ( "NumPTLsInVPS",                                   m_numPtlsInVps,                               1, "Number of profile_tier_level structures in VPS" )
   ( "PtPresentInPTL%d",                               m_ptPresentInPtl,               0, MAX_NUM_OLSS, "Profile/Tier present in i-th PTL")
   ( "AvoidIntraInDepLayers",                          m_avoidIntraInDepLayer,                    true, "Replaces I pictures in dependent layers with B pictures" )
-  ( "MaxTidILRefPicsPlusOneLayerId%d",                m_maxTidILRefPicsPlus1Str, string(""), MAX_VPS_LAYERS, "Maximum temporal ID for inter-layer reference pictures plus 1 of i-th layer, 0 for IRAP only")
+  ( "MaxTidILRefPicsPlusOneLayerId%d",                m_maxTidILRefPicsPlus1Str, std::string(""), MAX_VPS_LAYERS, "Maximum temporal ID for inter-layer reference pictures plus 1 of i-th layer, 0 for IRAP only")
   ( "RPLofDepLayerInSH",                              m_rplOfDepLayerInSh,                      false, "define Reference picture lists in slice header instead of SPS for dependant layers")
     ;
 
@@ -1828,11 +1823,15 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 
     std::ostringstream uriTag;
     uriTag << "SEINNPostFilterCharacteristicsUriTag" << i;
-    opts.addOptions()(uriTag.str(), m_nnPostFilterSEICharacteristicsUriTag[i], string(""), "Specifies the neural network uri tag in the Neural Network Post Filter Characteristics SEI message");
+    opts.addOptions()(
+      uriTag.str(), m_nnPostFilterSEICharacteristicsUriTag[i], std::string(""),
+      "Specifies the neural network uri tag in the Neural Network Post Filter Characteristics SEI message");
 
     std::ostringstream uri;
     uri << "SEINNPostFilterCharacteristicsUri" << i;
-    opts.addOptions()(uri.str(), m_nnPostFilterSEICharacteristicsUri[i], string(""), "Specifies the neural network information uri in the Neural Network Post Filter Characteristics SEI message");
+    opts.addOptions()(
+      uri.str(), m_nnPostFilterSEICharacteristicsUri[i], std::string(""),
+      "Specifies the neural network information uri in the Neural Network Post Filter Characteristics SEI message");
 
     std::ostringstream parameterTypeIdc;
     parameterTypeIdc << "SEINNPostFilterCharacteristicsParameterTypeIdc" << i;
@@ -1856,7 +1855,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 
     std::ostringstream payloadFilename;
     payloadFilename << "SEINNPostFilterCharacteristicsPayloadFilename" << i;
-    opts.addOptions()(payloadFilename.str(), m_nnPostFilterSEICharacteristicsPayloadFilename[i], string(""), "Specifies the NNR bitstream in the Neural Network Post Filter Characteristics SEI message");
+    opts.addOptions()(payloadFilename.str(), m_nnPostFilterSEICharacteristicsPayloadFilename[i], std::string(""),
+                      "Specifies the NNR bitstream in the Neural Network Post Filter Characteristics SEI message");
 
     std::ostringstream numberDecodedInputPics;
     numberDecodedInputPics << "SEINNPostFilterCharacteristicsNumberInputDecodedPicsMinusTwo" << i;
@@ -1874,7 +1874,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
 
   po::setDefaults(opts);
   po::ErrorReporter err;
-  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv, err);
+  const std::list<const char *> &argv_unhandled = po::scanArgv(opts, argc, (const char **) argv, err);
 
   if (m_gopBasedRPREnabledFlag)
   {
@@ -2077,7 +2077,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
     }
   }
 
-  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+  for (std::list<const char *>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
     msg( ERROR, "Unhandled argument ignored: `%s'\n", *it);
   }
@@ -2085,7 +2085,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] )
   if (argc == 1 || do_help)
   {
     /* argc == 1: no options have been specified */
-    po::doHelp(cout, opts);
+    po::doHelp(std::cout, opts);
     return false;
   }
 
@@ -4232,11 +4232,11 @@ bool EncAppCfg::xCheckParameter()
         }
 
         m_RPLList0[m_gopSize + extraRPLs].m_numRefPics = newRefs0;
-        m_RPLList0[m_gopSize + extraRPLs].m_numRefPicsActive =
-          min(m_RPLList0[m_gopSize + extraRPLs].m_numRefPics, m_RPLList0[m_gopSize + extraRPLs].m_numRefPicsActive);
+        m_RPLList0[m_gopSize + extraRPLs].m_numRefPicsActive = std::min(
+          m_RPLList0[m_gopSize + extraRPLs].m_numRefPics, m_RPLList0[m_gopSize + extraRPLs].m_numRefPicsActive);
         m_RPLList1[m_gopSize + extraRPLs].m_numRefPics = newRefs1;
-        m_RPLList1[m_gopSize + extraRPLs].m_numRefPicsActive =
-          min(m_RPLList1[m_gopSize + extraRPLs].m_numRefPics, m_RPLList1[m_gopSize + extraRPLs].m_numRefPicsActive);
+        m_RPLList1[m_gopSize + extraRPLs].m_numRefPicsActive = std::min(
+          m_RPLList1[m_gopSize + extraRPLs].m_numRefPics, m_RPLList1[m_gopSize + extraRPLs].m_numRefPicsActive);
         curGOP = m_gopSize + extraRPLs;
         extraRPLs++;
       }
diff --git a/source/App/SEIFilmGrainApp/SEIFilmGrainApp.cpp b/source/App/SEIFilmGrainApp/SEIFilmGrainApp.cpp
index abd1b95f8248cd39a61f2a5d563b2714fd0e35b5..58c155c8307eadf467b763933c34f895211a8f03 100644
--- a/source/App/SEIFilmGrainApp/SEIFilmGrainApp.cpp
+++ b/source/App/SEIFilmGrainApp/SEIFilmGrainApp.cpp
@@ -44,8 +44,6 @@
 #include "DecoderLib/AnnexBread.h"
 #include "EncoderLib/AnnexBwrite.h"
 
-using namespace std;
-
 //! \ingroup SEIFilmGrainApp
 //! \{
 
@@ -147,18 +145,18 @@ void SEIFilmGrainApp::printSEIFilmGrainCharacteristics(SEIFilmGrainCharacteristi
 
 uint32_t SEIFilmGrainApp::process()
 {
-  ifstream bitstreamFileIn(m_bitstreamFileNameIn.c_str(), ifstream::in | ifstream::binary);
+  std::ifstream bitstreamFileIn(m_bitstreamFileNameIn.c_str(), std::ifstream::in | std::ifstream::binary);
   if (!bitstreamFileIn)
   {
     EXIT( "failed to open bitstream file " << m_bitstreamFileNameIn.c_str() << " for reading" ) ;
   }
 
-  ofstream bitstreamFileOut(m_bitstreamFileNameOut.c_str(), ifstream::out | ifstream::binary);
+  std::ofstream bitstreamFileOut(m_bitstreamFileNameOut.c_str(), std::ifstream::out | std::ifstream::binary);
 
   InputByteStream bytestream(bitstreamFileIn);
 
   bitstreamFileIn.clear();
-  bitstreamFileIn.seekg( 0, ios::beg );
+  bitstreamFileIn.seekg(0, std::ios::beg);
 
   int NALUcount = 0;
   int SEIcount = 0;
diff --git a/source/App/SEIFilmGrainApp/SEIFilmGrainAppCfg.cpp b/source/App/SEIFilmGrainApp/SEIFilmGrainAppCfg.cpp
index 60a4529a28bdfe4819f7972350c078e95a4394d2..3f5a6da545ab368771ccdb80a27d9c20e35a1550 100644
--- a/source/App/SEIFilmGrainApp/SEIFilmGrainAppCfg.cpp
+++ b/source/App/SEIFilmGrainApp/SEIFilmGrainAppCfg.cpp
@@ -44,14 +44,12 @@
 #include "CommonLib/dtrace_next.h"
 #endif
 
-using namespace std;
 namespace po = df::program_options_lite;
 
 //! \ingroup SEIFilmGrainApp
 //! \{
 
-template <class T>
-static inline istream& operator >> (std::istream &in, SMultiValueInput<T> &values)
+template<class T> static inline std::istream &operator>>(std::istream &in, SMultiValueInput<T> &values)
 {
   return values.readValues(in);
 }
@@ -72,14 +70,15 @@ T SMultiValueInput<T>::readValue(const char *&pStr, bool &bSuccess)
   return val;
 }
 
-template <class T>
-istream& SMultiValueInput<T>::readValues(std::istream &in)
+template<class T> std::istream &SMultiValueInput<T>::readValues(std::istream &in)
 {
   values.clear();
-  string str;
+  std::string str;
   while (!in.eof())
   {
-    string tmp; in >> tmp; str += " " + tmp;
+    std::string tmp;
+    in >> tmp;
+    str += " " + tmp;
   }
   if (!str.empty())
   {
@@ -93,13 +92,13 @@ istream& SMultiValueInput<T>::readValues(std::istream &in)
       T val = readValue(pStr, bSuccess);
       if (!bSuccess)
       {
-        in.setstate(ios::failbit);
+        in.setstate(std::ios::failbit);
         break;
       }
 
       if (maxNumValuesIncl != 0 && values.size() >= maxNumValuesIncl)
       {
-        in.setstate(ios::failbit);
+        in.setstate(std::ios::failbit);
         break;
       }
       values.push_back(val);
@@ -114,7 +113,7 @@ istream& SMultiValueInput<T>::readValues(std::istream &in)
   }
   if (values.size() < minNumValuesIncl)
   {
-    in.setstate(ios::failbit);
+    in.setstate(std::ios::failbit);
   }
   return in;
 }
@@ -148,12 +147,13 @@ bool SEIFilmGrainAppCfg::parseCfg( int argc, char* argv[] )
   SMultiValueInput<uint32_t>    cfg_FgcSEICompModelValueComp2(0, 65535, 0, 256 * 6);
 
   po::Options opts;
-  opts.addOptions()
 
+  // clang-format off
+  opts.addOptions()
   ("help",                      do_help,                               false,      "this help text")
   ("c",                         po::parseConfigFile,                               "film grain configuration file name")
-  ("BitstreamFileIn,b",         m_bitstreamFileNameIn,                 string(""), "bitstream input file name")
-  ("BitstreamFileOut,o",        m_bitstreamFileNameOut,                string(""), "bitstream output file name")
+  ("BitstreamFileIn,b",         m_bitstreamFileNameIn,                 std::string(""), "bitstream input file name")
+  ("BitstreamFileOut,o",        m_bitstreamFileNameOut,                std::string(""), "bitstream output file name")
   ("SEIFilmGrainOption",        m_seiFilmGrainOption,                  0,          "process FGC SEI option (0:disable, 1:remove, 2:insert, 3:change)" )
   ("SEIFilmGrainPrint",         m_seiFilmGrainPrint,                   false,      "print output film grain characteristics SEI message (1:enable)")
 // film grain characteristics SEI
@@ -187,24 +187,25 @@ bool SEIFilmGrainAppCfg::parseCfg( int argc, char* argv[] )
 
 #if ENABLE_TRACING
   ("TraceChannelsList",         printTracingChannelsList,              false,      "List all available tracing channels" )
-  ("TraceRule",                 tracingRule,                           string(""), "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")" )
-  ("TraceFile",                 tracingFile,                           string(""), "Tracing file" )
+  ("TraceRule",                 tracingRule,                           std::string(""), "Tracing rule (ex: \"D_CABAC:poc==8\" or \"D_REC_CB_LUMA:poc==8\")" )
+  ("TraceFile",                 tracingFile,                           std::string(""), "Tracing file" )
 #endif
   ("WarnUnknowParameter,w",     warnUnknowParameter,                   0,          "warn for unknown configuration parameters instead of failing")
   ;
+  // clang-format on
 
   po::setDefaults(opts);
   po::ErrorReporter err;
-  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv, err);
+  const std::list<const char *> &argv_unhandled = po::scanArgv(opts, argc, (const char **) argv, err);
 
-  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+  for (std::list<const char *>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
     std::cerr << "Unhandled argument ignored: "<< *it << std::endl;
   }
 
   if (argc == 1 || do_help)
   {
-    po::doHelp(cout, opts);
+    po::doHelp(std::cout, opts);
     return false;
   }
 
diff --git a/source/App/SEIRemovalApp/SEIRemovalApp.cpp b/source/App/SEIRemovalApp/SEIRemovalApp.cpp
index eb131787660532f4e2932706f686319f8e5177c9..30524f7bad30f86cac1a91f34d362052eb10360f 100644
--- a/source/App/SEIRemovalApp/SEIRemovalApp.cpp
+++ b/source/App/SEIRemovalApp/SEIRemovalApp.cpp
@@ -44,8 +44,6 @@
 #include "DecoderLib/AnnexBread.h"
 #include "DecoderLib/NALread.h"
 
-using namespace std;
-
 //! \ingroup DecoderApp
 //! \{
 
@@ -83,18 +81,18 @@ void read2(InputNALUnit& nalu)
 
 uint32_t SEIRemovalApp::decode()
 {
-  ifstream bitstreamFileIn(m_bitstreamFileNameIn.c_str(), ifstream::in | ifstream::binary);
+  std::ifstream bitstreamFileIn(m_bitstreamFileNameIn.c_str(), std::ifstream::in | std::ifstream::binary);
   if (!bitstreamFileIn)
   {
     EXIT( "failed to open bitstream file " << m_bitstreamFileNameIn.c_str() << " for reading" ) ;
   }
 
-  ofstream bitstreamFileOut(m_bitstreamFileNameOut.c_str(), ifstream::out | ifstream::binary);
+  std::ofstream bitstreamFileOut(m_bitstreamFileNameOut.c_str(), std::ifstream::out | std::ifstream::binary);
 
   InputByteStream bytestream(bitstreamFileIn);
 
   bitstreamFileIn.clear();
-  bitstreamFileIn.seekg( 0, ios::beg );
+  bitstreamFileIn.seekg(0, std::ios::beg);
 
   int unitCnt = 0;
 
diff --git a/source/App/SEIRemovalApp/SEIRemovalAppCfg.cpp b/source/App/SEIRemovalApp/SEIRemovalAppCfg.cpp
index bcd2c3f3d2701785916c768644826912fd464134..24b587b7dce99ca9f45aa8d0d1a61c2f19824b1c 100644
--- a/source/App/SEIRemovalApp/SEIRemovalAppCfg.cpp
+++ b/source/App/SEIRemovalApp/SEIRemovalAppCfg.cpp
@@ -41,7 +41,6 @@
 #include "SEIRemovalAppCfg.h"
 #include "Utilities/program_options_lite.h"
 
-using namespace std;
 namespace po = df::program_options_lite;
 
 //! \ingroup DecoderApp
@@ -59,11 +58,12 @@ bool SEIRemovalAppCfg::parseCfg( int argc, char* argv[] )
   bool do_help = false;
   int warnUnknowParameter = 0;
   po::Options opts;
-  opts.addOptions()
 
+  // clang-format off
+  opts.addOptions()
   ("help",                      do_help,                               false,      "this help text")
-  ("BitstreamFileIn,b",         m_bitstreamFileNameIn,                 string(""), "bitstream input file name")
-  ("BitstreamFileOut,o",        m_bitstreamFileNameOut,                string(""), "bitstream output file name")
+  ("BitstreamFileIn,b",         m_bitstreamFileNameIn,                 std::string(""), "bitstream input file name")
+  ("BitstreamFileOut,o",        m_bitstreamFileNameOut,                std::string(""), "bitstream output file name")
   ("DiscardPrefixSEI,p",        m_discardPrefixSEIs,                   false,      "remove all prefix SEIs (default: 0)")
   ("DiscardSuffixSEI,s",        m_discardSuffixSEIs,                   true,       "remove all suffix SEIs (default: 1)")
   ("NumSkip",                   m_numNALUnitsToSkip,                   0,          "number of NAL units to skip (counted inclusive the units skipped with -p/-s options)" )
@@ -71,19 +71,20 @@ bool SEIRemovalAppCfg::parseCfg( int argc, char* argv[] )
 
   ("WarnUnknowParameter,w",     warnUnknowParameter,                   0,          "warn for unknown configuration parameters instead of failing")
   ;
+  // clang-format on
 
   po::setDefaults(opts);
   po::ErrorReporter err;
-  const list<const char*>& argv_unhandled = po::scanArgv(opts, argc, (const char**) argv, err);
+  const std::list<const char *> &argv_unhandled = po::scanArgv(opts, argc, (const char **) argv, err);
 
-  for (list<const char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+  for (std::list<const char *>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
     std::cerr << "Unhandled argument ignored: "<< *it << std::endl;
   }
 
   if (argc == 1 || do_help)
   {
-    po::doHelp(cout, opts);
+    po::doHelp(std::cout, opts);
     return false;
   }
 
diff --git a/source/App/StreamMergeApp/StreamMergeApp.cpp b/source/App/StreamMergeApp/StreamMergeApp.cpp
index fa1ba45992296c9b235b405aa0d1f87cabd3363f..02ff59ece1f3cdc46b7d14e80c74d6afa19aee76 100644
--- a/source/App/StreamMergeApp/StreamMergeApp.cpp
+++ b/source/App/StreamMergeApp/StreamMergeApp.cpp
@@ -47,8 +47,6 @@
 #include "CommonLib/CodingStatistics.h"
 #endif
 
-using namespace std;
-
 //! \ingroup DecoderApp
 //! \{
 
@@ -65,12 +63,8 @@ StreamMergeApp::StreamMergeApp()
 // Public member functions
 // ====================================================================================================================
 
-static void
-_byteStreamNALUnit(
-  SingleLayerStream& bs,
-  std::istream& istream,
-  vector<uint8_t>& nalUnit,
-  AnnexBStats& stats)
+static void _byteStreamNALUnit(SingleLayerStream &bs, std::istream &istream, std::vector<uint8_t> &nalUnit,
+                               AnnexBStats &stats)
 {
   /* At the beginning of the decoding process, the decoder initialises its
    * current position in the byte stream to the beginning of the byte stream.
@@ -186,12 +180,7 @@ _byteStreamNALUnit(
  * Returns false if EOF was reached (NB, nalunit data may be valid),
  *         otherwise true.
  */
-bool
-byteStreamNALUnit(
-  SingleLayerStream& bs,
-  std::istream& istream,
-  vector<uint8_t>& nalUnit,
-  AnnexBStats& stats)
+bool byteStreamNALUnit(SingleLayerStream &bs, std::istream &istream, std::vector<uint8_t> &nalUnit, AnnexBStats &stats)
 {
   bool eof = false;
   try
@@ -520,9 +509,9 @@ void StreamMergeApp::decodeAndRewriteNalu(MergeLayer &layer, InputNALUnit &inNal
     }
     msg(INFO, " with index %i", inNalu.m_nalUnitType);
     // Copy payload from input nalu to output nalu. Code copied from SubpicMergeApp::copyInputNaluToOutputNalu().
-    vector<uint8_t> &inFifo  = inNalu.getBitstream().getFifo();
-    vector<uint8_t> &outFifo = outNalu.m_bitstream.getFifo();
-    outFifo                  = vector<uint8_t>(inFifo.begin() + 2, inFifo.end());
+    std::vector<uint8_t> &inFifo  = inNalu.getBitstream().getFifo();
+    std::vector<uint8_t> &outFifo = outNalu.m_bitstream.getFifo();
+    outFifo                       = std::vector<uint8_t>(inFifo.begin() + 2, inFifo.end());
     break;
   }
   }
@@ -531,9 +520,9 @@ void StreamMergeApp::decodeAndRewriteNalu(MergeLayer &layer, InputNALUnit &inNal
 
 uint32_t StreamMergeApp::mergeStreams()
 {
-  ofstream outputStream(m_bitstreamFileNameOut, ifstream::out | ifstream::binary);
+  std::ofstream outputStream(m_bitstreamFileNameOut, std::ifstream::out | std::ifstream::binary);
 
-  vector<MergeLayer> *layers = new vector<MergeLayer>;
+  std::vector<MergeLayer> *layers = new std::vector<MergeLayer>;
   layers->resize(m_numInputStreams);
 
   // Prepare merge layers.
@@ -543,14 +532,14 @@ uint32_t StreamMergeApp::mergeStreams()
     layer.id          = i;
 
     // Open input file.
-    layer.fp = new ifstream();
-    layer.fp->open(m_bitstreamFileNameIn[i], ifstream::in | ifstream::binary);
+    layer.fp = new std::ifstream();
+    layer.fp->open(m_bitstreamFileNameIn[i], std::ifstream::in | std::ifstream::binary);
     if (!layer.fp->is_open())
     {
       EXIT("failed to open bitstream file " << m_bitstreamFileNameIn[i] << " for reading");
     }
     layer.fp->clear();
-    layer.fp->seekg(0, ios::beg);
+    layer.fp->seekg(0, std::ios::beg);
 
     // Prep other values.
     layer.bs = new InputByteStream(*(layer.fp));
diff --git a/source/App/StreamMergeApp/StreamMergeAppCfg.cpp b/source/App/StreamMergeApp/StreamMergeAppCfg.cpp
index e8b63f3598471de805ddfdc5bd5aefb1e33cf027..14605d03d1d0ea92c28f230981696575b9b66c11 100644
--- a/source/App/StreamMergeApp/StreamMergeAppCfg.cpp
+++ b/source/App/StreamMergeApp/StreamMergeAppCfg.cpp
@@ -41,7 +41,6 @@
 #include "StreamMergeAppCfg.h"
 #include "Utilities/program_options_lite.h"
 
-using namespace std;
 namespace po = df::program_options_lite;
 
 //! \ingroup DecoderApp
diff --git a/source/Lib/CommonLib/BitStream.cpp b/source/Lib/CommonLib/BitStream.cpp
index efc856cb861887c9b004f6ddb0867496245ec6e0..b0f31db80eeedf1620fb2ebc20dee9e628993382 100644
--- a/source/Lib/CommonLib/BitStream.cpp
+++ b/source/Lib/CommonLib/BitStream.cpp
@@ -41,8 +41,6 @@
 #include <string.h>
 #include <memory.h>
 
-using namespace std;
-
 //! \ingroup CommonLib
 //! \{
 
@@ -173,7 +171,7 @@ void   OutputBitstream::addSubstream( OutputBitstream* pcSubstream )
 {
   uint32_t numBits = pcSubstream->getNumberOfWrittenBits();
 
-  const vector<uint8_t> &rbsp = pcSubstream->getFifo();
+  const std::vector<uint8_t> &rbsp = pcSubstream->getFifo();
   for (const uint8_t byte: rbsp)
   {
     write(byte, BITS_PER_BYTE);
@@ -196,10 +194,10 @@ void OutputBitstream::writeByteAlignment()
 int OutputBitstream::countStartCodeEmulations()
 {
   uint32_t cnt = 0;
-  vector<uint8_t> &rbsp = getFifo();
-  for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
+  std::vector<uint8_t> &rbsp = getFifo();
+  for (std::vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
   {
-    vector<uint8_t>::iterator found = it;
+    std::vector<uint8_t>::iterator found = it;
     do
     {
       // find the next emulated 00 00 {00,01,02,03}
@@ -239,7 +237,7 @@ void InputBitstream::pseudoRead(uint32_t numberOfBits, uint32_t &bits)
   uint8_t  savedHeldBits    = m_heldBits;
   uint32_t savedFifoIdx     = m_fifoIdx;
 
-  uint32_t numBitsToRead = min(numberOfBits, getNumBitsLeft());
+  uint32_t numBitsToRead = std::min(numberOfBits, getNumBitsLeft());
   read(numBitsToRead, bits);
   bits <<= (numberOfBits - numBitsToRead);
 
diff --git a/source/Lib/CommonLib/IbcHashMap.cpp b/source/Lib/CommonLib/IbcHashMap.cpp
index 75155aff914e6bc0737e07becba3d66bf74d883e..76776308b08d8bdae73153e287e6b0fe41f4f870 100644
--- a/source/Lib/CommonLib/IbcHashMap.cpp
+++ b/source/Lib/CommonLib/IbcHashMap.cpp
@@ -40,9 +40,6 @@
 #include "CommonLib/UnitTools.h"
 #include "IbcHashMap.h"
 
-
-using namespace std;
-
 //! \ingroup IbcHashMap
 //! \{
 
diff --git a/source/Lib/DecoderLib/AnnexBread.cpp b/source/Lib/DecoderLib/AnnexBread.cpp
index 95e5fd14e16d53efbb7e9cf577bd184326ed967d..101342d32f1f027887b204bc08ec86dd16e2f23c 100644
--- a/source/Lib/DecoderLib/AnnexBread.cpp
+++ b/source/Lib/DecoderLib/AnnexBread.cpp
@@ -44,8 +44,6 @@
 #include "CommonLib/CodingStatistics.h"
 #endif
 
-using namespace std;
-
 //! \ingroup DecoderLib
 //! \{
 
@@ -57,11 +55,7 @@ using namespace std;
  * of std::ios_base::failure is thrown.  The contsnts of stats will
  * be correct at this point.
  */
-static void
-_byteStreamNALUnit(
-  InputByteStream& bs,
-  vector<uint8_t>& nalUnit,
-  AnnexBStats& stats)
+static void _byteStreamNALUnit(InputByteStream &bs, std::vector<uint8_t> &nalUnit, AnnexBStats &stats)
 {
   /* At the beginning of the decoding process, the decoder initialises its
    * current position in the byte stream to the beginning of the byte stream.
@@ -196,11 +190,7 @@ _byteStreamNALUnit(
  * Returns false if EOF was reached (NB, nalunit data may be valid),
  *         otherwise true.
  */
-bool
-byteStreamNALUnit(
-  InputByteStream& bs,
-  vector<uint8_t>& nalUnit,
-  AnnexBStats& stats)
+bool byteStreamNALUnit(InputByteStream &bs, std::vector<uint8_t> &nalUnit, AnnexBStats &stats)
 {
   bool eof = false;
   try
diff --git a/source/Lib/DecoderLib/NALread.cpp b/source/Lib/DecoderLib/NALread.cpp
index 217f3eb8c265ec54a09204d41fd0108627fb46ce..7a39ed130d25a7362efc9d461162f6ddfb3febd3 100644
--- a/source/Lib/DecoderLib/NALread.cpp
+++ b/source/Lib/DecoderLib/NALread.cpp
@@ -52,14 +52,12 @@
 #include "CommonLib/CodingStatistics.h"
 #endif
 
-using namespace std;
-
 //! \ingroup DecoderLib
 //! \{
-static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, InputBitstream *bitstream, bool isVclNalUnit)
+static void convertPayloadToRBSP(std::vector<uint8_t> &nalUnitBuf, InputBitstream *bitstream, bool isVclNalUnit)
 {
   uint32_t zeroCount = 0;
-  vector<uint8_t>::iterator it_read, it_write;
+  std::vector<uint8_t>::iterator it_read, it_write;
 
   uint32_t pos = 0;
   bitstream->clearEmulationPreventionByteLocation();
@@ -162,7 +160,7 @@ void readNalUnitHeader(InputNALUnit& nalu)
 void read(InputNALUnit& nalu)
 {
   InputBitstream &bitstream = nalu.getBitstream();
-  vector<uint8_t>& nalUnitBuf=bitstream.getFifo();
+  std::vector<uint8_t> &nalUnitBuf = bitstream.getFifo();
   // perform anti-emulation prevention
   const NalUnitType nut = (NalUnitType)(nalUnitBuf[1] >> 3);
   convertPayloadToRBSP(nalUnitBuf, &bitstream, nut <= NAL_UNIT_RESERVED_IRAP_VCL_11);
diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp
index 904c86e9b650cd7ee4eb48ad89de0c669d1aac05..2227bc2f9a9af6a3b2a48629cb0aac93e809f323 100644
--- a/source/Lib/EncoderLib/EncCu.cpp
+++ b/source/Lib/EncoderLib/EncCu.cpp
@@ -53,8 +53,6 @@
 #include <cmath>
 #include <algorithm>
 
-using namespace std;
-
 //! \ingroup EncoderLib
 //! \{
 
@@ -2166,7 +2164,7 @@ void EncCu::xCheckRDCostHashInter( CodingStructure *&tempCS, CodingStructure *&b
     }
   }
   tempCS->initStructData(encTestMode.qp);
-  int minSize = min(cu.lwidth(), cu.lheight());
+  int minSize = std::min(cu.lwidth(), cu.lheight());
   if (minSize < 64)
   {
     isPerfectMatch = false;
@@ -2380,15 +2378,15 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
         {
           if (insertPos == rdModeList.size() - 1)
           {
-            swap(singleMergeTempBuffer, rdOrderedMrgPredBuf[insertPos]);
+            std::swap(singleMergeTempBuffer, rdOrderedMrgPredBuf[insertPos]);
           }
           else
           {
             for (uint32_t i = uint32_t(rdModeList.size()) - 1; i > insertPos; i--)
             {
-              swap(rdOrderedMrgPredBuf[i - 1], rdOrderedMrgPredBuf[i]);
+              std::swap(rdOrderedMrgPredBuf[i - 1], rdOrderedMrgPredBuf[i]);
             }
-            swap(singleMergeTempBuffer, rdOrderedMrgPredBuf[insertPos]);
+            std::swap(singleMergeTempBuffer, rdOrderedMrgPredBuf[insertPos]);
           }
         }
 #if !GDR_ENABLED
@@ -2482,9 +2480,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
           {
             for (int i = int(rdModeList.size()) - 1; i > insertPos; i--)
             {
-              swap(rdOrderedMrgPredBuf[i - 1], rdOrderedMrgPredBuf[i]);
+              std::swap(rdOrderedMrgPredBuf[i - 1], rdOrderedMrgPredBuf[i]);
             }
-            swap(singleMergeTempBuffer, rdOrderedMrgPredBuf[insertPos]);
+            std::swap(singleMergeTempBuffer, rdOrderedMrgPredBuf[insertPos]);
           }
         }
         pu->ciipFlag = false;
@@ -2559,9 +2557,9 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&
           {
             for (int i = int(rdModeList.size()) - 1; i > insertPos; i--)
             {
-              swap(rdOrderedMrgPredBuf[i - 1], rdOrderedMrgPredBuf[i]);
+              std::swap(rdOrderedMrgPredBuf[i - 1], rdOrderedMrgPredBuf[i]);
             }
-            swap(singleMergeTempBuffer, rdOrderedMrgPredBuf[insertPos]);
+            std::swap(singleMergeTempBuffer, rdOrderedMrgPredBuf[insertPos]);
           }
         }
       }
@@ -3015,8 +3013,8 @@ void EncCu::xCheckRDCostMergeGeo2Nx2N(CodingStructure *&tempCS, CodingStructure
   m_pcRdCost->setDistParam(distParamSAD2, tempCS->getOrgBuf().Y(), tempCS->getOrgBuf().Y(),
                            sps.getBitDepth(ChannelType::LUMA), COMPONENT_Y, useHadamard);
 
-  const int geoNumMrgSadCand  = min(GEO_MAX_TRY_WEIGHTED_SAD, (int) comboList.list.size());
-  int geoNumMrgSatdCand = min(GEO_MAX_TRY_WEIGHTED_SATD, (int) comboList.list.size());
+  const int geoNumMrgSadCand  = std::min(GEO_MAX_TRY_WEIGHTED_SAD, (int) comboList.list.size());
+  int       geoNumMrgSatdCand = std::min(GEO_MAX_TRY_WEIGHTED_SATD, (int) comboList.list.size());
 
   for (int candidateIdx = 0; candidateIdx < geoNumMrgSadCand; candidateIdx++)
   {
diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp
index fbf02e705bf8c5ce8c9d673e6bad8baf87db873d..8a108844c469f37936bd1a43fc376b0ecd418b01 100644
--- a/source/Lib/EncoderLib/EncGOP.cpp
+++ b/source/Lib/EncoderLib/EncGOP.cpp
@@ -59,8 +59,6 @@
 
 #include "DecoderLib/DecLib.h"
 
-using namespace std;
-
 //! \ingroup EncoderLib
 //! \{
 
@@ -2041,14 +2039,14 @@ void EncGOP::xPicInitRateControl(int &estimatedBits, int gopId, double &lambda,
       m_pcRateCtrl->getRCPic()->setTargetBits( bits );
     }
 
-    list<EncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
+    std::list<EncRCPic *> listPreviousPicture = m_pcRateCtrl->getPicList();
     m_pcRateCtrl->getRCPic()->getLCUInitTargetBits();
     lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, slice->isIRAP());
     sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
   }
   else    // normal case
   {
-    list<EncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
+    std::list<EncRCPic *> listPreviousPicture = m_pcRateCtrl->getPicList();
     lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, slice->isIRAP());
     sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
   }
@@ -2324,7 +2322,7 @@ void EncGOP::compressGOP(int pocLast, int numPicRcvd, PicList &rcListPic, std::l
 
   if( isField && picIdInGOP == 0 )
   {
-    for (int gopId = 0; gopId < max(2, m_iGopSize); gopId++)
+    for (int gopId = 0; gopId < std::max(2, m_iGopSize); gopId++)
     {
       m_pcCfg->setEncodedFlag(gopId, false);
     }
@@ -2706,11 +2704,11 @@ void EncGOP::compressGOP(int pocLast, int numPicRcvd, PicList &rcListPic, std::l
     {
       pcSlice->setNumRefIdx(REF_PIC_LIST_0, (pcSlice->isIntra())
                                               ? 0
-                                              : min(m_pcCfg->getRPLEntry(0, gopId).m_numRefPicsActive + 1,
+                                              : std::min(m_pcCfg->getRPLEntry(0, gopId).m_numRefPicsActive + 1,
                                                     pcSlice->getRpl(REF_PIC_LIST_0)->getNumberOfActivePictures()));
       pcSlice->setNumRefIdx(REF_PIC_LIST_1, (!pcSlice->isInterB())
                                               ? 0
-                                              : min(m_pcCfg->getRPLEntry(1, gopId).m_numRefPicsActive + 1,
+                                              : std::min(m_pcCfg->getRPLEntry(1, gopId).m_numRefPicsActive + 1,
                                                     pcSlice->getRpl(REF_PIC_LIST_1)->getNumberOfActivePictures()));
     }
     else
@@ -5193,9 +5191,8 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni
       uint64_t xPsnr[MAX_NUM_COMPONENT];
       for (int i = 0; i < MAX_NUM_COMPONENT; i++)
       {
-        copy(reinterpret_cast<uint8_t *>(&dPSNR[i]),
-             reinterpret_cast<uint8_t *>(&dPSNR[i]) + sizeof(dPSNR[i]),
-             reinterpret_cast<uint8_t *>(&xPsnr[i]));
+        std::copy(reinterpret_cast<uint8_t *>(&dPSNR[i]), reinterpret_cast<uint8_t *>(&dPSNR[i]) + sizeof(dPSNR[i]),
+                  reinterpret_cast<uint8_t *>(&xPsnr[i]));
       }
       msg(NOTICE, " [xY %16" PRIx64 " xU %16" PRIx64 " xV %16" PRIx64 "]", xPsnr[COMPONENT_Y], xPsnr[COMPONENT_Cb], xPsnr[COMPONENT_Cr]);
 
@@ -5223,9 +5220,9 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni
         uint64_t xPsnrWeighted[MAX_NUM_COMPONENT];
         for (int i = 0; i < MAX_NUM_COMPONENT; i++)
         {
-          copy(reinterpret_cast<uint8_t *>(&dPSNRWeighted[i]),
-               reinterpret_cast<uint8_t *>(&dPSNRWeighted[i]) + sizeof(dPSNRWeighted[i]),
-               reinterpret_cast<uint8_t *>(&xPsnrWeighted[i]));
+          std::copy(reinterpret_cast<uint8_t *>(&dPSNRWeighted[i]),
+                    reinterpret_cast<uint8_t *>(&dPSNRWeighted[i]) + sizeof(dPSNRWeighted[i]),
+                    reinterpret_cast<uint8_t *>(&xPsnrWeighted[i]));
         }
         msg(NOTICE, " [xWY %16" PRIx64 " xWU %16" PRIx64 " xWV %16" PRIx64 "]", xPsnrWeighted[COMPONENT_Y], xPsnrWeighted[COMPONENT_Cb], xPsnrWeighted[COMPONENT_Cr]);
       }
@@ -6171,8 +6168,8 @@ void EncGOP::arrangeCompositeReference(Slice* pcSlice, PicList& rcListPic, int p
         {
           if (minCtuCost[i].cost > minCtuCost[i + 1].cost)
           {
-            swap(minCtuCost[i].cost, minCtuCost[i + 1].cost);
-            swap(minCtuCost[i].ctuIdx, minCtuCost[i + 1].ctuIdx);
+            std::swap(minCtuCost[i].cost, minCtuCost[i + 1].cost);
+            std::swap(minCtuCost[i].ctuIdx, minCtuCost[i + 1].ctuIdx);
           }
         }
         // 2) compare the current cost with the largest cost
diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp
index 6b77221167d51d691a860da93ee49cf877943a55..6bdf8c4f698726fd741ebbc17e0151681f30fabd 100644
--- a/source/Lib/EncoderLib/EncLib.cpp
+++ b/source/Lib/EncoderLib/EncLib.cpp
@@ -46,8 +46,6 @@
 #include "EncLibCommon.h"
 #include "CommonLib/ProfileLevelTier.h"
 
-using namespace std;
-
 //! \ingroup EncoderLib
 //! \{
 
@@ -1524,7 +1522,8 @@ void EncLib::xInitSPS( SPS& sps )
   {
     sps.setBitDepth(channelType, m_bitDepth[channelType]);
     sps.setQpBDOffset(channelType, (6 * (m_bitDepth[channelType] - 8)));
-    sps.setInternalMinusInputBitDepth(channelType, max(0, (m_bitDepth[channelType] - m_inputBitDepth[channelType])));
+    sps.setInternalMinusInputBitDepth(channelType,
+                                      std::max(0, (m_bitDepth[channelType] - m_inputBitDepth[channelType])));
   }
 
   sps.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag );
@@ -1825,11 +1824,11 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps)
     const double dcrQP = m_wcgChromaQpControl.chromaCrQpScale * chromaQp;
     const int cbQP =(int)(dcbQP + ( dcbQP < 0 ? -0.5 : 0.5) );
     const int crQP =(int)(dcrQP + ( dcrQP < 0 ? -0.5 : 0.5) );
-    pps.setQpOffset(COMPONENT_Cb, Clip3( -12, 12, min(0, cbQP) + m_chromaCbQpOffset ));
-    pps.setQpOffset(COMPONENT_Cr, Clip3( -12, 12, min(0, crQP) + m_chromaCrQpOffset));
+    pps.setQpOffset(COMPONENT_Cb, Clip3(-12, 12, std::min(0, cbQP) + m_chromaCbQpOffset));
+    pps.setQpOffset(COMPONENT_Cr, Clip3(-12, 12, std::min(0, crQP) + m_chromaCrQpOffset));
     if(pps.getJointCbCrQpOffsetPresentFlag())
     {
-      pps.setQpOffset(JOINT_CbCr, Clip3(-12, 12, (min(0, cbQP) + min(0, crQP)) / 2 + m_chromaCbCrQpOffset));
+      pps.setQpOffset(JOINT_CbCr, Clip3(-12, 12, (std::min(0, cbQP) + std::min(0, crQP)) / 2 + m_chromaCbCrQpOffset));
     }
     else
     {
diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp
index 7319a32010ef055cd93629ae09029673ad3b5aa9..679b121117960a389455c21a27f9f4b8d3c94775 100644
--- a/source/Lib/EncoderLib/EncModeCtrl.cpp
+++ b/source/Lib/EncoderLib/EncModeCtrl.cpp
@@ -49,8 +49,6 @@
 
 #include <cmath>
 
-using namespace std;
-
 static constexpr double UNSET_IMV_COST = MAX_DOUBLE * 0.125;   // Some large, unique value
 
 void EncModeCtrl::init( EncCfg *pCfg, RateCtrl *pRateCtrl, RdCost* pRdCost )
@@ -323,7 +321,7 @@ int EncModeCtrl::calculateLumaDQPsmooth(const CPelBuf& rcOrg, int baseQP, double
     }
     if (diff < thr)
     {
-      qp = max(limit, min(0, (int)(scale*(double)baseQP + offset)));
+      qp = std::max(limit, std::min(0, (int) (scale * (double) baseQP + offset)));
     }
   }
   return qp;
@@ -1386,7 +1384,7 @@ void EncModeCtrlMTnoRQT::initCULevel( Partitioner &partitioner, const CodingStru
       }
       if (m_pcEncCfg->getUseHashME())
       {
-        int minSize = min(cs.area.lwidth(), cs.area.lheight());
+        int minSize = std::min(cs.area.lwidth(), cs.area.lheight());
         if (minSize < 128 && minSize >= 4)
         {
           m_ComprCUCtxList.back().testModes.push_back({ ETM_HASH_INTER, ETO_STANDARD, qp });
diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp
index 117f2849f23871ff20f45f1b7ea30be76683ac19..c3a246ff1e24127efff66b5294b5813cf84c3aea 100644
--- a/source/Lib/EncoderLib/InterSearch.cpp
+++ b/source/Lib/EncoderLib/InterSearch.cpp
@@ -53,8 +53,6 @@
 #include <math.h>
 #include <limits>
 
-using namespace std;
-
 //! \ingroup EncoderLib
 //! \{
 
@@ -1916,7 +1914,7 @@ void InterSearch::selectMatchesInter(const MapIterator& itBegin, int count, std:
 void InterSearch::selectRectangleMatchesInter(const MapIterator& itBegin, int count, std::list<BlockHash>& listBlockHash, const BlockHash& currBlockHash, int width, int height, int idxNonSimple, unsigned int* &hashValues, int baseNum, int picWidth, int picHeight, bool isHorizontal, uint16_t* curHashPic)
 {
   const int maxReturnNumber = 5;
-  int baseSize = min(width, height);
+  int          baseSize        = std::min(width, height);
   unsigned int crcMask = 1 << 16;
   crcMask -= 1;
 
@@ -1990,7 +1988,7 @@ bool InterSearch::xRectHashInterEstimation(PredictionUnit& pu, RefPicList& bestR
   int width = pu.cu->lumaSize().width;
   int height = pu.cu->lumaSize().height;
 
-  int baseSize = min(width, height);
+  int  baseSize     = std::min(width, height);
   bool isHorizontal = true;;
   int baseNum = 0;
   if (height < width)
@@ -2098,7 +2096,7 @@ bool InterSearch::xRectHashInterEstimation(PredictionUnit& pu, RefPicList& bestR
           continue;
         }
 
-        list<BlockHash> listBlockHash;
+        std::list<BlockHash> listBlockHash;
         selectRectangleMatchesInter(pu.cu->slice->getRefPic(eRefPicList, refIdx)->getHashMap()->getFirstIterator(hashValue1s[idxNonSimple]), count, listBlockHash, currBlockHash, width, height, idxNonSimple, hashValue2s, baseNum, picWidth, picHeight, isHorizontal, pu.cu->slice->getRefPic(eRefPicList, refIdx)->getHashMap()->getHashPic(baseSize));
 
         m_numHashMVStoreds[eRefPicList][refIdx] = int(listBlockHash.size());
@@ -2151,7 +2149,7 @@ bool InterSearch::xRectHashInterEstimation(PredictionUnit& pu, RefPicList& bestR
         m_pcRdCost->selectMotionLambda( );
         m_pcRdCost->setCostScale(0);
 
-        list<BlockHash>::iterator it;
+        std::list<BlockHash>::iterator it;
         int countMV = 0;
         for (it = listBlockHash.begin(); it != listBlockHash.end(); ++it)
         {
@@ -2400,7 +2398,7 @@ bool InterSearch::xHashInterEstimation(PredictionUnit& pu, RefPicList& bestRefPi
           continue;
         }
 
-        list<BlockHash> listBlockHash;
+        std::list<BlockHash> listBlockHash;
         selectMatchesInter(pu.cu->slice->getRefPic(eRefPicList, refIdx)->getHashMap()->getFirstIterator(hashValue1), count, listBlockHash, currBlockHash);
         m_numHashMVStoreds[eRefPicList][refIdx] = (int)listBlockHash.size();
         if (listBlockHash.empty())
@@ -2468,7 +2466,7 @@ bool InterSearch::xHashInterEstimation(PredictionUnit& pu, RefPicList& bestRefPi
         m_pcRdCost->selectMotionLambda( );
         m_pcRdCost->setCostScale(0);
 
-        list<BlockHash>::iterator it;
+        std::list<BlockHash>::iterator it;
         int countMV = 0;
         for (it = listBlockHash.begin(); it != listBlockHash.end(); ++it)
         {
@@ -5512,7 +5510,7 @@ void InterSearch::xTZSearch(const PredictionUnit &pu, RefPicList eRefPicList, in
   }
   if (m_pcEncCfg->getUseHashME() && (m_currRefPicList == 0 || pu.cu->slice->getList1IdxToList0Idx(m_currRefPicIndex) < 0))
   {
-    int minSize = min(pu.cu->lumaSize().width, pu.cu->lumaSize().height);
+    int minSize = std::min(pu.cu->lumaSize().width, pu.cu->lumaSize().height);
     if (minSize < 128 && minSize >= 4)
     {
       int numberOfOtherMvps = m_numHashMVStoreds[m_currRefPicList][m_currRefPicIndex];
@@ -5815,7 +5813,7 @@ void InterSearch::xTZSearchSelective(const PredictionUnit &pu, RefPicList eRefPi
   }
   if (m_pcEncCfg->getUseHashME() && (m_currRefPicList == 0 || pu.cu->slice->getList1IdxToList0Idx(m_currRefPicIndex) < 0))
   {
-    int minSize = min(pu.cu->lumaSize().width, pu.cu->lumaSize().height);
+    int minSize = std::min(pu.cu->lumaSize().width, pu.cu->lumaSize().height);
     if (minSize < 128 && minSize >= 4)
     {
       int numberOfOtherMvps = m_numHashMVStoreds[m_currRefPicList][m_currRefPicIndex];
diff --git a/source/Lib/EncoderLib/NALwrite.cpp b/source/Lib/EncoderLib/NALwrite.cpp
index 7fcc4a504a7920eb93c18d9a73cd9177b3a811aa..62e36b34cf66a65aa4edbfdddfbde0492a886057 100644
--- a/source/Lib/EncoderLib/NALwrite.cpp
+++ b/source/Lib/EncoderLib/NALwrite.cpp
@@ -39,14 +39,12 @@
 #include "CommonLib/BitStream.h"
 #include "NALwrite.h"
 
-using namespace std;
-
 //! \ingroup EncoderLib
 //! \{
 
 static const uint8_t emulation_prevention_three_byte = 3;
 
-void writeNalUnitHeader(ostream& out, OutputNALUnit& nalu)       // nal_unit_header()
+void writeNalUnitHeader(std::ostream &out, OutputNALUnit &nalu)   // nal_unit_header()
 {
   OutputBitstream bsNALUHeader;
   int forbiddenZero = 0;
@@ -65,7 +63,7 @@ void writeNalUnitHeader(ostream& out, OutputNALUnit& nalu)       // nal_unit_hea
  * write nalu to bytestream out, performing RBSP anti startcode
  * emulation as required.  nalu.m_RBSPayload must be byte aligned.
  */
-void writeNaluContent(ostream& out, OutputNALUnit& nalu)
+void writeNaluContent(std::ostream &out, OutputNALUnit &nalu)
 {
   /* write out rsbp_byte's, inserting any required
    * emulation_prevention_three_byte's */
@@ -87,13 +85,13 @@ void writeNaluContent(ostream& out, OutputNALUnit& nalu)
    *  - 0x00000302
    *  - 0x00000303
    */
-  vector<uint8_t> &rbsp = nalu.m_bitstream.getFifo();
+  std::vector<uint8_t> &rbsp = nalu.m_bitstream.getFifo();
 
-  vector<uint8_t> outputBuffer;
+  std::vector<uint8_t> outputBuffer;
   outputBuffer.resize(rbsp.size()*2+1); //there can never be enough emulation_prevention_three_bytes to require this much space
   std::size_t outputAmount = 0;
   int         zeroCount    = 0;
-  for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end(); it++)
+  for (std::vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end(); it++)
   {
     const uint8_t v=(*it);
     if (zeroCount==2 && v<=3)
@@ -125,7 +123,7 @@ void writeNaluContent(ostream& out, OutputNALUnit& nalu)
   out.write(reinterpret_cast<const char*>(&(*outputBuffer.begin())), outputAmount);
 }
 
-void writeNaluWithHeader(ostream& out, OutputNALUnit& nalu)
+void writeNaluWithHeader(std::ostream &out, OutputNALUnit &nalu)
 {
   writeNalUnitHeader(out, nalu);
   writeNaluContent(out, nalu);
diff --git a/source/Lib/EncoderLib/RateCtrl.cpp b/source/Lib/EncoderLib/RateCtrl.cpp
index 116d009c2a956c86b34615e8385e76c8459027d3..a1a69679b71d6d801fb6795dd8add68787406cca 100644
--- a/source/Lib/EncoderLib/RateCtrl.cpp
+++ b/source/Lib/EncoderLib/RateCtrl.cpp
@@ -41,8 +41,6 @@
 
 #define LAMBDA_PREC                                           1000000
 
-using namespace std;
-
 //sequence level
 EncRCSeq::EncRCSeq()
 {
@@ -618,7 +616,9 @@ void EncRCGOP::updateAfterPicture( int bitsCost )
 
 int EncRCGOP::xEstGOPTargetBits( EncRCSeq* encRCSeq, int GOPSize )
 {
-  int realInfluencePicture = min(g_RCSmoothWindowSizeAlpha * GOPSize / max(encRCSeq->getIntraPeriod(), 32) + g_RCSmoothWindowSizeBeta, encRCSeq->getFramesLeft());
+  int realInfluencePicture =
+    std::min(g_RCSmoothWindowSizeAlpha * GOPSize / std::max(encRCSeq->getIntraPeriod(), 32) + g_RCSmoothWindowSizeBeta,
+             encRCSeq->getFramesLeft());
   int averageTargetBitsPerPic = (int)( encRCSeq->getTargetBits() / encRCSeq->getTotalFrames() );
   int currentTargetBitsPerPic = (int)( ( encRCSeq->getBitsLeft() - averageTargetBitsPerPic * (encRCSeq->getFramesLeft() - realInfluencePicture) ) / realInfluencePicture );
   int targetBits = currentTargetBitsPerPic * GOPSize;
@@ -692,12 +692,12 @@ int EncRCPic::xEstPicTargetBits( EncRCSeq* encRCSeq, EncRCGOP* encRCGOP )
   return targetBits;
 }
 
-int EncRCPic::xEstPicHeaderBits( list<EncRCPic*>& listPreviousPictures, int frameLevel )
+int EncRCPic::xEstPicHeaderBits(std::list<EncRCPic *> &listPreviousPictures, int frameLevel)
 {
   int numPreviousPics   = 0;
   int totalPreviousBits = 0;
 
-  list<EncRCPic*>::iterator it;
+  std::list<EncRCPic *>::iterator it;
   for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ )
   {
     if ( (*it)->getFrameLevel() == frameLevel )
@@ -754,7 +754,7 @@ int EncRCPic::xEstPicLowerBound(EncRCSeq* encRCSeq, EncRCGOP* encRCGOP)
   return lowerBound;
 }
 
-void EncRCPic::addToPictureLsit( list<EncRCPic*>& listPreviousPictures )
+void EncRCPic::addToPictureLsit(std::list<EncRCPic *> &listPreviousPictures)
 {
   if ( listPreviousPictures.size() > g_RCMaxPicListSize )
   {
@@ -767,7 +767,8 @@ void EncRCPic::addToPictureLsit( list<EncRCPic*>& listPreviousPictures )
   listPreviousPictures.push_back( this );
 }
 
-void EncRCPic::create( EncRCSeq* encRCSeq, EncRCGOP* encRCGOP, int frameLevel, list<EncRCPic*>& listPreviousPictures )
+void EncRCPic::create(EncRCSeq *encRCSeq, EncRCGOP *encRCGOP, int frameLevel,
+                      std::list<EncRCPic *> &listPreviousPictures)
 {
   destroy();
   m_encRCSeq = encRCSeq;
@@ -839,8 +840,7 @@ void EncRCPic::destroy()
   m_encRCGOP = nullptr;
 }
 
-
-double EncRCPic::estimatePicLambda( list<EncRCPic*>& listPreviousPictures, bool isIRAP)
+double EncRCPic::estimatePicLambda(std::list<EncRCPic *> &listPreviousPictures, bool isIRAP)
 {
   double alpha         = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
   double beta          = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
@@ -873,7 +873,7 @@ double EncRCPic::estimatePicLambda( list<EncRCPic*>& listPreviousPictures, bool
   double lastLevelLambda = -1.0;
   double lastPicLambda   = -1.0;
   double lastValidLambda = -1.0;
-  list<EncRCPic*>::iterator it;
+  std::list<EncRCPic *>::iterator it;
   for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ )
   {
     if ( (*it)->getFrameLevel() == m_frameLevel )
@@ -951,7 +951,7 @@ double EncRCPic::estimatePicLambda( list<EncRCPic*>& listPreviousPictures, bool
   return estLambda;
 }
 
-int EncRCPic::estimatePicQP( double lambda, list<EncRCPic*>& listPreviousPictures )
+int EncRCPic::estimatePicQP(double lambda, std::list<EncRCPic *> &listPreviousPictures)
 {
   int bitdepth_luma_scale =
     2
@@ -963,7 +963,7 @@ int EncRCPic::estimatePicQP( double lambda, list<EncRCPic*>& listPreviousPicture
   int lastLevelQP = g_RCInvalidQPValue;
   int lastPicQP   = g_RCInvalidQPValue;
   int lastValidQP = g_RCInvalidQPValue;
-  list<EncRCPic*>::iterator it;
+  std::list<EncRCPic *>::iterator it;
   for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ )
   {
     if ( (*it)->getFrameLevel() == m_frameLevel )
@@ -1002,7 +1002,7 @@ double EncRCPic::getLCUTargetBpp(bool isIRAP)
 
   if (isIRAP)
   {
-    int bitrateWindow = min(4, m_LCULeft);
+    int    bitrateWindow = std::min(4, m_LCULeft);
     double MAD      = getLCU(LCUIdx).m_costIntra;
 
     if (m_remainingCostIntra > 0.1 )
@@ -1023,7 +1023,7 @@ double EncRCPic::getLCUTargetBpp(bool isIRAP)
     {
       totalWeight += m_LCUs[i].m_bitWeight;
     }
-    int realInfluenceLCU = min( g_RCLCUSmoothWindowSize, getLCULeft() );
+    int realInfluenceLCU = std::min(g_RCLCUSmoothWindowSize, getLCULeft());
     avgBits = (int)( m_LCUs[LCUIdx].m_bitWeight - ( totalWeight - m_bitsLeft ) / realInfluenceLCU + 0.5 );
   }
 
@@ -1397,8 +1397,8 @@ double EncRCPic::getLCUEstLambdaAndQP(double bpp, int clipPicQP, int *estQP)
 
   if ( clipNeighbourQP > g_RCInvalidQPValue )
   {
-    maxQP = min(clipNeighbourQP + 1, maxQP);
-    minQP = max(clipNeighbourQP - 1, minQP);
+    maxQP = std::min(clipNeighbourQP + 1, maxQP);
+    minQP = std::max(clipNeighbourQP - 1, minQP);
   }
 
   int bitdepth_luma_scale =
diff --git a/source/Lib/EncoderLib/SEIEncoder.cpp b/source/Lib/EncoderLib/SEIEncoder.cpp
index 6be778d562d104d86ca52caa4bf5e4948b57fea2..4e96a2c3c9d79053cd241347bfe81d1d6ba4c9b1 100644
--- a/source/Lib/EncoderLib/SEIEncoder.cpp
+++ b/source/Lib/EncoderLib/SEIEncoder.cpp
@@ -37,8 +37,6 @@
 #include "EncLib.h"
 #include <fstream>
 
-using namespace std;
-
 uint32_t calcMD5(const CPelUnitBuf& pic, PictureHash &digest, const BitDepths &bitDepths);
 uint32_t calcCRC(const CPelUnitBuf& pic, PictureHash &digest, const BitDepths &bitDepths);
 uint32_t calcChecksum(const CPelUnitBuf& pic, PictureHash &digest, const BitDepths &bitDepths);
@@ -244,11 +242,19 @@ void SEIEncoder::initSEIGreenMetadataInfo(SEIGreenMetadataInfo* seiGreenMetadata
     seiGreenMetadataInfo->m_xsdSubpicNumberMinus1 = m_pcCfg->getSEIXSDNumberMetrics()-1;
     seiGreenMetadataInfo->m_xsdSubPicIdc = 1; //Only 1 Picture is supported
     // Maximum valid value for 16-bit integer: 65535
-    (m_pcCfg->getSEIXSDMetricTypePSNR()) ? seiGreenMetadataInfo->m_xsdMetricValuePSNR  = min(int(metrics.psnr*100),65535) :  seiGreenMetadataInfo->m_xsdMetricValuePSNR = 0;
-    (m_pcCfg->getSEIXSDMetricTypeSSIM()) ? seiGreenMetadataInfo->m_xsdMetricValueSSIM  = min(int(metrics.ssim*100),65535) : seiGreenMetadataInfo->m_xsdMetricValueSSIM  = 0;
-    (m_pcCfg->getSEIXSDMetricTypeWPSNR()) ? seiGreenMetadataInfo->m_xsdMetricValueWPSNR  = min(int(metrics.wpsnr*100),65535) : seiGreenMetadataInfo->m_xsdMetricValueWPSNR  = 0;
-    (m_pcCfg->getSEIXSDMetricTypeWSPSNR()) ? seiGreenMetadataInfo->m_xsdMetricValueWSPSNR  = min(int(metrics.wspsnr*100),65535) : seiGreenMetadataInfo->m_xsdMetricValueWSPSNR  = 0;
-    
+    (m_pcCfg->getSEIXSDMetricTypePSNR())
+      ? seiGreenMetadataInfo->m_xsdMetricValuePSNR = std::min(int(metrics.psnr * 100), 65535)
+      : seiGreenMetadataInfo->m_xsdMetricValuePSNR = 0;
+    (m_pcCfg->getSEIXSDMetricTypeSSIM())
+      ? seiGreenMetadataInfo->m_xsdMetricValueSSIM = std::min(int(metrics.ssim * 100), 65535)
+      : seiGreenMetadataInfo->m_xsdMetricValueSSIM = 0;
+    (m_pcCfg->getSEIXSDMetricTypeWPSNR())
+      ? seiGreenMetadataInfo->m_xsdMetricValueWPSNR = std::min(int(metrics.wpsnr * 100), 65535)
+      : seiGreenMetadataInfo->m_xsdMetricValueWPSNR = 0;
+    (m_pcCfg->getSEIXSDMetricTypeWSPSNR())
+      ? seiGreenMetadataInfo->m_xsdMetricValueWSPSNR = std::min(int(metrics.wspsnr * 100), 65535)
+      : seiGreenMetadataInfo->m_xsdMetricValueWSPSNR = 0;
+
     seiGreenMetadataInfo->m_xsdMetricTypePSNR = m_pcCfg->getSEIXSDMetricTypePSNR();
     seiGreenMetadataInfo->m_xsdMetricTypeSSIM = m_pcCfg->getSEIXSDMetricTypeSSIM();
     seiGreenMetadataInfo->m_xsdMetricTypeWPSNR = m_pcCfg->getSEIXSDMetricTypeWPSNR();
@@ -514,7 +520,7 @@ void SEIEncoder::initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI,
     scalableNestingSEI->m_snSubpicFlag = 1;
     scalableNestingSEI->m_snNumSubpics = (uint32_t) subpictureIDs.size();
     scalableNestingSEI->m_snSubpicId   = subpictureIDs;
-    scalableNestingSEI->m_snSubpicIdLen = max(1, ceilLog2(maxSubpicIdInPic + 1));
+    scalableNestingSEI->m_snSubpicIdLen = std::max(1, ceilLog2(maxSubpicIdInPic + 1));
     CHECK ( scalableNestingSEI->m_snSubpicIdLen > 16, "Subpicture ID too large. Length must be <= 16 bits");
   }
   scalableNestingSEI->m_nestedSEIs.clear();
@@ -1390,8 +1396,8 @@ void SEIEncoder::initSEINeuralNetworkPostFilterCharacteristics(SEINeuralNetworkP
   }
   if (sei->m_modeIdc == 1)
   {
-    const string payloadFilename = m_pcCfg->getNNPostFilterSEICharacteristicsPayloadFilename(filterIdx);
-    ifstream bitstreamFile(payloadFilename.c_str(), ifstream::in | ifstream::binary);
+    const std::string payloadFilename = m_pcCfg->getNNPostFilterSEICharacteristicsPayloadFilename(filterIdx);
+    std::ifstream     bitstreamFile(payloadFilename.c_str(), std::ifstream::in | std::ifstream::binary);
     if (!bitstreamFile)
     {
       EXIT( "Failed to open bitstream file " << payloadFilename.c_str() << " for reading" ) ;
diff --git a/source/Lib/EncoderLib/SEIFilmGrainAnalyzer.cpp b/source/Lib/EncoderLib/SEIFilmGrainAnalyzer.cpp
index ef00d2e601610bcaf13b00781bff90d71fec8ebc..8c5e4703fd7c1e30d765c5355192bbd063a7f668 100644
--- a/source/Lib/EncoderLib/SEIFilmGrainAnalyzer.cpp
+++ b/source/Lib/EncoderLib/SEIFilmGrainAnalyzer.cpp
@@ -37,8 +37,6 @@
 
 #include "SEIFilmGrainAnalyzer.h"
 
-using namespace std;
-
 constexpr double FGAnalyser::m_tapFilter[3];
 
 // ====================================================================================================================
@@ -909,8 +907,8 @@ void FGAnalyser::estimate_scaling_factors(std::vector<int> &data_x, std::vector<
 void FGAnalyser::estimate_cutoff_freq(const std::vector<PelMatrix> &blocks, ComponentID compID)
 {
   PelMatrixDouble mean_squared_dct_grain(DATA_BASE_SIZE, std::vector<double>(DATA_BASE_SIZE));
-  vector<double>  vec_mean_dct_grain_row(DATA_BASE_SIZE, 0.0);
-  vector<double>  vec_mean_dct_grain_col(DATA_BASE_SIZE, 0.0);
+  std::vector<double> vec_mean_dct_grain_row(DATA_BASE_SIZE, 0.0);
+  std::vector<double> vec_mean_dct_grain_col(DATA_BASE_SIZE, 0.0);
   static bool     isFirstCutoffEst[MAX_NUM_COMPONENT] = {true, true, true };
 
   int num_blocks = (int) blocks.size();
@@ -1284,14 +1282,14 @@ bool FGAnalyser::fit_function(std::vector<int> &data_x, std::vector<int> &data_y
   }
 
   // release memory for data_x and data_y, and clear previous vectors
-  vector<int>().swap(tmp_data_x);
-  vector<int>().swap(tmp_data_y);
+  std::vector<int>().swap(tmp_data_x);
+  std::vector<int>().swap(tmp_data_y);
   if (second_pass)
   {
-    vector<int>().swap(data_x);
-    vector<int>().swap(data_y);
-    vector<double>().swap(coeffs);
-    vector<double>().swap(scalingVec);
+    std::vector<int>().swap(data_x);
+    std::vector<int>().swap(data_y);
+    std::vector<double>().swap(coeffs);
+    std::vector<double>().swap(scalingVec);
   }
 
   for (i = 1; i <= data_pairs; i++)
diff --git a/source/Lib/Utilities/VideoIOYuv.cpp b/source/Lib/Utilities/VideoIOYuv.cpp
index 73f5ab9865ea2874ad71916776d4022f606af0f0..f5ebe33422ae6b1a2d801bf189b6ceefc80adbab 100644
--- a/source/Lib/Utilities/VideoIOYuv.cpp
+++ b/source/Lib/Utilities/VideoIOYuv.cpp
@@ -46,8 +46,6 @@
 #include "VideoIOYuv.h"
 #include "CommonLib/Unit.h"
 
-using namespace std;
-
 #define FLIP_PIC 0
 
 constexpr int Y4M_SIGNATURE_LENGTH    = 10;
@@ -155,7 +153,7 @@ void VideoIOYuv::open(const std::string &fileName, bool bWriteMode, const BitDep
 
   if ( bWriteMode )
   {
-    m_cHandle.open( fileName.c_str(), ios::binary | ios::out );
+    m_cHandle.open(fileName.c_str(), std::ios::binary | std::ios::out);
 
     if( m_cHandle.fail() )
     {
@@ -178,7 +176,7 @@ void VideoIOYuv::open(const std::string &fileName, bool bWriteMode, const BitDep
         parseY4mFileHeader(fileName, dummyWidth, dummyHeight, dummyFrameRate, dummyBitDepth, dummyChromaFormat);
       }
     }
-    m_cHandle.open( fileName.c_str(), ios::binary | ios::in );
+    m_cHandle.open(fileName.c_str(), std::ios::binary | std::ios::in);
 
     if( m_cHandle.fail() )
     {
@@ -187,7 +185,7 @@ void VideoIOYuv::open(const std::string &fileName, bool bWriteMode, const BitDep
 
     if (m_inY4mFileHeaderLength)
     {
-      m_cHandle.seekg(m_inY4mFileHeaderLength, ios::cur);
+      m_cHandle.seekg(m_inY4mFileHeaderLength, std::ios::cur);
     }
   }
 
@@ -197,7 +195,7 @@ void VideoIOYuv::open(const std::string &fileName, bool bWriteMode, const BitDep
 void VideoIOYuv::parseY4mFileHeader(const std::string &fileName, int &width, int &height, int &frameRate, int &bitDepth,
                                ChromaFormat &chromaFormat)
 {
-  m_cHandle.open(fileName.c_str(), ios::binary | ios::in);
+  m_cHandle.open(fileName.c_str(), std::ios::binary | std::ios::in);
   CHECK(m_cHandle.fail(), "File open failed.")
 
   char header[Y4M_MAX_HEADER_LENGTH];
@@ -349,7 +347,7 @@ void VideoIOYuv::skipFrames(uint32_t numFrames, uint32_t width, uint32_t height,
 
   //------------------
   //set the frame size according to the chroma format
-  streamoff frameSize = 0;
+  std::streamoff frameSize = 0;
   uint32_t wordsize=1; // default to 8-bit, unless a channel with more than 8-bits is detected.
   for (uint32_t component = 0; component < getNumberValidComponents(format); component++)
   {
@@ -367,10 +365,10 @@ void VideoIOYuv::skipFrames(uint32_t numFrames, uint32_t width, uint32_t height,
     frameSize += Y4M_FRAME_HEADER_LENGTH;
   }
 
-  const streamoff offset = frameSize * numFrames;
+  const std::streamoff offset = frameSize * numFrames;
 
   /* attempt to seek */
-  if (!!m_cHandle.seekg(offset, ios::cur))
+  if (!!m_cHandle.seekg(offset, std::ios::cur))
   {
     return; /* success */
   }
@@ -378,8 +376,8 @@ void VideoIOYuv::skipFrames(uint32_t numFrames, uint32_t width, uint32_t height,
 
   /* fall back to consuming the input */
   char buf[512];
-  const streamoff offset_mod_bufsize = offset % sizeof(buf);
-  for (streamoff i = 0; i < offset - offset_mod_bufsize; i += sizeof(buf))
+  const std::streamoff offset_mod_bufsize = offset % sizeof(buf);
+  for (std::streamoff i = 0; i < offset - offset_mod_bufsize; i += sizeof(buf))
   {
     m_cHandle.read(buf, sizeof(buf));
   }
@@ -405,9 +403,9 @@ void VideoIOYuv::skipFrames(uint32_t numFrames, uint32_t width, uint32_t height,
  * @param fileBitDepth component bit depth in file
  * @return true for success, false in case of error
  */
-static bool readPlane(Pel *dst, istream &fd, bool is16bit, ptrdiff_t stride444, uint32_t width444, uint32_t height444,
-                      uint32_t pad_x444, uint32_t pad_y444, const ComponentID compID, const ChromaFormat destFormat,
-                      const ChromaFormat fileFormat, const uint32_t fileBitDepth)
+static bool readPlane(Pel *dst, std::istream &fd, bool is16bit, ptrdiff_t stride444, uint32_t width444,
+                      uint32_t height444, uint32_t pad_x444, uint32_t pad_y444, const ComponentID compID,
+                      const ChromaFormat destFormat, const ChromaFormat fileFormat, const uint32_t fileBitDepth)
 {
   const uint32_t csx_file =getComponentScaleX(compID, fileFormat);
   const uint32_t csy_file =getComponentScaleY(compID, fileFormat);
@@ -452,7 +450,7 @@ static bool readPlane(Pel *dst, istream &fd, bool is16bit, ptrdiff_t stride444,
     if (fileFormat!=CHROMA_400)
     {
       const uint32_t height_file      = height444>>csy_file;
-      fd.seekg(height_file*stride_file, ios::cur);
+      fd.seekg(height_file * stride_file, std::ios::cur);
       if (fd.eof() || fd.fail() )
       {
         return false;
@@ -588,7 +586,7 @@ static bool verifyPlane(Pel *dst, ptrdiff_t stride444, uint32_t width444, uint32
  * @param fileBitDepth component bit depth in file
  * @return true for success, false in case of error
  */
-static bool writePlane(uint32_t orgWidth, uint32_t orgHeight, ostream &fd, const Pel *src, const bool is16bit,
+static bool writePlane(uint32_t orgWidth, uint32_t orgHeight, std::ostream &fd, const Pel *src, const bool is16bit,
                        const ptrdiff_t stride_src, uint32_t width444, uint32_t height444, const ComponentID compID,
                        const ChromaFormat srcFormat, const ChromaFormat fileFormat, const uint32_t fileBitDepth,
                        const uint32_t packedYUVOutputMode = 0)
@@ -862,10 +860,10 @@ static bool writePlane(uint32_t orgWidth, uint32_t orgHeight, ostream &fd, const
   return true;
 }
 
-static bool writeField(ostream &fd, const Pel *top, const Pel *bottom, const bool is16bit, const ptrdiff_t stride_src,
-                       uint32_t width444, uint32_t height444, const ComponentID compID, const ChromaFormat srcFormat,
-                       const ChromaFormat fileFormat, const uint32_t fileBitDepth, const bool isTff,
-                       const uint32_t packedYUVOutputMode = 0)
+static bool writeField(std::ostream &fd, const Pel *top, const Pel *bottom, const bool is16bit,
+                       const ptrdiff_t stride_src, uint32_t width444, uint32_t height444, const ComponentID compID,
+                       const ChromaFormat srcFormat, const ChromaFormat fileFormat, const uint32_t fileBitDepth,
+                       const bool isTff, const uint32_t packedYUVOutputMode = 0)
 {
   const uint32_t csx_file =getComponentScaleX(compID, fileFormat);
   const uint32_t csy_file =getComponentScaleY(compID, fileFormat);
diff --git a/source/Lib/Utilities/program_options_lite.cpp b/source/Lib/Utilities/program_options_lite.cpp
index e3b07606396e19d2c07d06de43ade457f863e46e..b9f301e9022a41e200be1ec9c12f326a7a1a1f0f 100644
--- a/source/Lib/Utilities/program_options_lite.cpp
+++ b/source/Lib/Utilities/program_options_lite.cpp
@@ -40,8 +40,6 @@
 #include <algorithm>
 #include "program_options_lite.h"
 
-using namespace std;
-
 //! \ingroup TAppCommon
 //! \{
 
@@ -51,17 +49,17 @@ namespace df
   {
     ErrorReporter default_error_reporter;
 
-    ostream& ErrorReporter::error(const string& where)
+    std::ostream &ErrorReporter::error(const std::string &where)
     {
       is_errored = 1;
-      cerr << where << " error: ";
-      return cerr;
+      std::cerr << where << " error: ";
+      return std::cerr;
     }
 
-    ostream& ErrorReporter::warn(const string& where)
+    std::ostream &ErrorReporter::warn(const std::string &where)
     {
-      cerr << where << " warning: ";
-      return cerr;
+      std::cerr << where << " warning: ";
+      return std::cerr;
     }
 
     Options::~Options()
@@ -76,10 +74,10 @@ namespace df
     {
       Names* names = new Names();
       names->opt = opt;
-      string& opt_string = opt->opt_string;
+      std::string &opt_string = opt->opt_string;
 
       size_t opt_start = 0;
-      for (size_t opt_end = 0; opt_end != string::npos;)
+      for (size_t opt_end = 0; opt_end != std::string::npos;)
       {
         opt_end = opt_string.find_first_of(',', opt_start);
         bool force_short = 0;
@@ -88,7 +86,7 @@ namespace df
           opt_start++;
           force_short = 1;
         }
-        string opt_name = opt_string.substr(opt_start, opt_end - opt_start);
+        std::string opt_name = opt_string.substr(opt_start, opt_end - opt_start);
         if (force_short || opt_name.size() == 1)
         {
           names->opt_short.push_back(opt_name);
@@ -99,7 +97,7 @@ namespace df
 #if JVET_O0549_ENCODER_ONLY_FILTER_POL
           if (opt_name.size() > 0 && opt_name.back() == '*')
           {
-            string prefix_name = opt_name.substr(0, opt_name.size() - 1);
+            std::string prefix_name = opt_name.substr(0, opt_name.size() - 1);
             names->opt_prefix.push_back(prefix_name);
             opt_prefix_map[prefix_name].push_back(names);
           }
@@ -124,7 +122,7 @@ namespace df
       return OptionSpecific(*this);
     }
 
-    static void setOptions(Options::NamesPtrList& opt_list, const string& value, ErrorReporter& error_reporter)
+    static void setOptions(Options::NamesPtrList &opt_list, const std::string &value, ErrorReporter &error_reporter)
     {
       /* multiple options may be registered for the same name:
        *   allow each to parse value */
@@ -140,13 +138,13 @@ namespace df
      * using the formatting: "-x, --long",
      * if a short/long option isn't specified, it is not printed
      */
-    static void doHelpOpt(ostream& out, const Options::Names& entry, unsigned pad_short = 0)
+    static void doHelpOpt(std::ostream &out, const Options::Names &entry, unsigned pad_short = 0)
     {
-      pad_short = min(pad_short, 8u);
+      pad_short = std::min(pad_short, 8u);
 
       if (!entry.opt_short.empty())
       {
-        unsigned pad = max((int)pad_short - (int)entry.opt_short.front().size(), 0);
+        unsigned pad = std::max((int) pad_short - (int) entry.opt_short.front().size(), 0);
         out << "-" << entry.opt_short.front();
         if (!entry.opt_long.empty())
         {
@@ -173,19 +171,19 @@ namespace df
     }
 
     /* format the help text */
-    void doHelp(ostream& out, Options& opts, unsigned columns)
+    void doHelp(std::ostream &out, Options &opts, unsigned columns)
     {
       const unsigned pad_short = 3;
       /* first pass: work out the longest option name */
       unsigned max_width = 0;
       for(Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++)
       {
-        ostringstream line(ios_base::out);
+        std::ostringstream line(std::ios_base::out);
         doHelpOpt(line, **it, pad_short);
-        max_width = max(max_width, (unsigned) line.tellp());
+        max_width = std::max(max_width, (unsigned) line.tellp());
       }
 
-      unsigned opt_width = min(max_width+2, 28u + pad_short) + 2;
+      unsigned opt_width  = std::min(max_width + 2, 28u + pad_short) + 2;
       unsigned desc_width = columns - opt_width;
 
       /* second pass: write out formatted option and help text.
@@ -195,15 +193,15 @@ namespace df
        */
       for(Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++)
       {
-        ostringstream line(ios_base::out);
+        std::ostringstream line(std::ios_base::out);
         line << "  ";
         doHelpOpt(line, **it, pad_short);
 
-        const string& opt_desc = (*it)->opt->opt_desc;
+        const std::string &opt_desc = (*it)->opt->opt_desc;
         if (opt_desc.empty())
         {
           /* no help text: output option, skip further processing */
-          cout << line.str() << endl;
+          std::cout << line.str() << std::endl;
           continue;
         }
         size_t currlength = size_t(line.tellp());
@@ -211,17 +209,17 @@ namespace df
         {
           /* if option text is too long (and would collide with the
            * help text, split onto next line */
-          line << endl;
+          line << std::endl;
           currlength = 0;
         }
         /* split up the help text, taking into account new lines,
          *   (add opt_width of padding to each new line) */
-        for (size_t newline_pos = 0, cur_pos = 0; cur_pos != string::npos; currlength = 0)
+        for (size_t newline_pos = 0, cur_pos = 0; cur_pos != std::string::npos; currlength = 0)
         {
           /* print any required padding space for vertical alignment */
           line << &(spaces[40 - opt_width + currlength]);
           newline_pos = opt_desc.find_first_of('\n', newline_pos);
-          if (newline_pos != string::npos)
+          if (newline_pos != std::string::npos)
           {
             /* newline found, print substring (newline needn't be stripped) */
             newline_pos++;
@@ -237,14 +235,14 @@ namespace df
           }
           /* find a suitable point to split text (avoid spliting in middle of word) */
           size_t split_pos = opt_desc.find_last_of(' ', cur_pos + desc_width);
-          if (split_pos != string::npos)
+          if (split_pos != std::string::npos)
           {
             /* eat up multiple space characters */
             split_pos = opt_desc.find_last_not_of(' ', split_pos) + 1;
           }
 
           /* bad split if no suitable space to split at.  fall back to width */
-          bool bad_split = split_pos == string::npos || split_pos <= cur_pos;
+          bool bad_split = split_pos == std::string::npos || split_pos <= cur_pos;
           if (bad_split)
           {
             split_pos = cur_pos + desc_width;
@@ -262,10 +260,10 @@ namespace df
           {
             break;
           }
-          line << endl;
+          line << std::endl;
         }
 
-        cout << line.str() << endl;
+        std::cout << line.str() << std::endl;
       }
     }
 
@@ -276,19 +274,16 @@ namespace df
       {}
       virtual ~OptionWriter() {}
 
-      virtual const string where() = 0;
+      virtual const std::string where() = 0;
 
-      bool storePair(bool allow_long, bool allow_short, const string& name, const string& value);
-      bool storePair(const string& name, const string& value)
-      {
-        return storePair(true, true, name, value);
-      }
+      bool storePair(bool allow_long, bool allow_short, const std::string &name, const std::string &value);
+      bool storePair(const std::string &name, const std::string &value) { return storePair(true, true, name, value); }
 
       Options& opts;
       ErrorReporter& error_reporter;
     };
 
-    bool OptionWriter::storePair(bool allow_long, bool allow_short, const string& name, const string& value)
+    bool OptionWriter::storePair(bool allow_long, bool allow_short, const std::string &name, const std::string &value)
     {
       bool found = false;
 #if JVET_O0549_ENCODER_ONLY_FILTER_POL
@@ -350,7 +345,7 @@ namespace df
       : OptionWriter(rOpts, rError_reporter)
       {}
 
-      const string where() { return "command line"; }
+      const std::string where() { return "command line"; }
 
       unsigned parseGNU(unsigned argc, const char* argv[]);
       unsigned parseSHORT(unsigned argc, const char* argv[]);
@@ -365,13 +360,13 @@ namespace df
        *  --option=arg
        *  --option arg
        */
-      string arg(argv[0]);
+      std::string arg(argv[0]);
       size_t arg_opt_start = arg.find_first_not_of('-');
       size_t arg_opt_sep = arg.find_first_of('=');
-      string option = arg.substr(arg_opt_start, arg_opt_sep - arg_opt_start);
+      std::string option        = arg.substr(arg_opt_start, arg_opt_sep - arg_opt_start);
 
       unsigned extra_argc_consumed = 0;
-      if (arg_opt_sep == string::npos)
+      if (arg_opt_sep == std::string::npos)
       {
         /* no argument found => argument in argv[1] (maybe) */
         /* xxx, need to handle case where option isn't required */
@@ -383,7 +378,7 @@ namespace df
       else
       {
         /* argument occurs after option_sep */
-        string val = arg.substr(arg_opt_sep + 1);
+        std::string val = arg.substr(arg_opt_sep + 1);
         storePair(true, false, option, val);
       }
 
@@ -396,9 +391,9 @@ namespace df
        *  --option arg
        *  -option arg
        */
-      string arg(argv[0]);
+      std::string arg(argv[0]);
       size_t arg_opt_start = arg.find_first_not_of('-');
-      string option = arg.substr(arg_opt_start);
+      std::string option        = arg.substr(arg_opt_start);
       /* lookup option */
 
       /* argument in argv[1] */
@@ -409,18 +404,17 @@ namespace df
           << "Not processing option `" << option << "' without argument\n";
         return 0; /* run out of argv for argument */
       }
-      storePair(false, true, option, string(argv[1]));
+      storePair(false, true, option, std::string(argv[1]));
 
       return 1;
     }
 
-    list<const char*>
-    scanArgv(Options& opts, unsigned argc, const char* argv[], ErrorReporter& error_reporter)
+    std::list<const char *> scanArgv(Options &opts, unsigned argc, const char *argv[], ErrorReporter &error_reporter)
     {
       ArgvParser avp(opts, error_reporter);
 
       /* a list for anything that didn't get handled as an option */
-      list<const char*> non_option_arguments;
+      std::list<const char *> non_option_arguments;
 
       for(unsigned i = 1; i < argc; i++)
       {
@@ -463,30 +457,28 @@ namespace df
 
     struct CfgStreamParser : public OptionWriter
     {
-      CfgStreamParser(const string& rName, Options& rOpts, ErrorReporter& rError_reporter)
-      : OptionWriter(rOpts, rError_reporter)
-      , name(rName)
-      , linenum(0)
+      CfgStreamParser(const std::string &rName, Options &rOpts, ErrorReporter &rError_reporter)
+        : OptionWriter(rOpts, rError_reporter), name(rName), linenum(0)
       {}
 
-      const string name;
+      const std::string name;
       int linenum;
-      const string where()
+      const std::string where()
       {
-        ostringstream os;
+        std::ostringstream os;
         os << name << ":" << linenum;
         return os.str();
       }
 
-      void scanLine(string& line);
-      void scanStream(istream& in);
+      void scanLine(std::string &line);
+      void scanStream(std::istream &in);
     };
 
-    void CfgStreamParser::scanLine(string& line)
+    void CfgStreamParser::scanLine(std::string &line)
     {
       /* strip any leading whitespace */
       size_t start = line.find_first_not_of(" \t\n\r");
-      if (start == string::npos)
+      if (start == std::string::npos)
       {
         /* blank line */
         return;
@@ -498,11 +490,11 @@ namespace df
       }
       /* look for first whitespace or ':' after the option end */
       size_t option_end = line.find_first_of(": \t\n\r",start);
-      string option = line.substr(start, option_end - start);
+      std::string option     = line.substr(start, option_end - start);
 
       /* look for ':', eat up any whitespace first */
       start = line.find_first_not_of(" \t\n\r", option_end);
-      if (start == string::npos)
+      if (start == std::string::npos)
       {
         /* error: badly formatted line */
         error_reporter.warn(where()) << "line formatting error\n";
@@ -517,7 +509,7 @@ namespace df
 
       /* look for start of value string -- eat up any leading whitespace */
       start = line.find_first_not_of(" \t\n\r", ++start);
-      if (start == string::npos)
+      if (start == std::string::npos)
       {
         /* error: badly formatted line */
         error_reporter.warn(where()) << "line formatting error\n";
@@ -539,11 +531,11 @@ namespace df
         /* consume any white space, incase there is another word.
          * any trailing whitespace will be removed shortly */
         value_end = line.find_first_not_of(" \t\n\r", value_end);
-      } while (value_end != string::npos);
+      } while (value_end != std::string::npos);
       /* strip any trailing space from value*/
       value_end = line.find_last_not_of(" \t\n\r", value_end);
 
-      string value;
+      std::string value;
       if (value_end >= start)
       {
         value = line.substr(start, value_end +1 - start);
@@ -559,12 +551,12 @@ namespace df
       storePair(true, false, option, value);
     }
 
-    void CfgStreamParser::scanStream(istream& in)
+    void CfgStreamParser::scanStream(std::istream &in)
     {
       do
       {
         linenum++;
-        string line;
+        std::string line;
         getline(in, line);
         scanLine(line);
       } while(!!in);
@@ -580,9 +572,9 @@ namespace df
       }
     }
 
-    void parseConfigFile(Options& opts, const string& filename, ErrorReporter& error_reporter)
+    void parseConfigFile(Options &opts, const std::string &filename, ErrorReporter &error_reporter)
     {
-      ifstream cfgstream(filename.c_str(), ifstream::in);
+      std::ifstream cfgstream(filename.c_str(), std::ifstream::in);
       if (!cfgstream)
       {
         error_reporter.error(filename) << "Failed to open config file\n";