diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h
index a183b0b819829dce94b525bebd83a8fcfd30a443..82753ac509fe1ca35ec7e5c81d221e4fd793b5ac 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h
@@ -3,43 +3,45 @@
 */
 
 /**
- *      @header file for SCT_RodEncoder Class
- *      This class provides conversion from SCT RDO to ROD format ByteStream.
- *      @date 21/06/07:  SCT_RodEncoder turned into An AlgTool 
- *      @author: Nick Barlow nbarlow@mail.cern.ch, Kondo.Gnanvo@cern.ch
- *  
+ * @file SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h
+ * @author: Nick Barlow (nbarlow@mail.cern.ch, Kondo.Gnanvo@cern.ch)
+ * @date 21 June 2007 (SCT_RodEncoder turned into An AlgTool)
+ * 
+ * This class provides conversion from SCT RDO to ROD format ByteStream.
  */
  
-#ifndef SCT_RAWDATABYTESTREAM_ISCT_RODENCODER_H
-#define SCT_RAWDATABYTESTREAM_ISCT_RODENCODER_H
-
-///STL
-#include <vector>
-#include <cstdint>
+#ifndef SCT_RAWDATABYTESTREAMCNV_ISCT_RODENCODER_H
+#define SCT_RAWDATABYTESTREAMCNV_ISCT_RODENCODER_H
 
 #include "GaudiKernel/IAlgTool.h"
 
-///InDet
-/** needed for typedef, cannot fwd declare */
-#include "InDetRawData/SCT_RDO_Container.h"
+#include <vector>
+#include <cstdint>
 
 class SCT_RDORawData;
 
-class ISCT_RodEncoder : virtual public IAlgTool {
+/**
+ * @class ISCT_RodEncoder
+ *
+ * @brief Interface for Athena Algorithm Tool to convert from SCT RDO to ROD format BysteStream.
+ * 
+ * Convert collections of RDO's to a vector of 32 bit word.
+ *
+ * This class inherits from IAlgTool.
+ */
+class ISCT_RodEncoder : virtual public IAlgTool 
+{
  public:
 
-  typedef SCT_RDORawData RDO;
-  typedef std::vector<const RDO*> vRDOs;
-  
-  /** destructor */
-  virtual ~ISCT_RodEncoder() = default;
-
-  /// Creates the InterfaceID and interfaceID() method
+  /** Creates the InterfaceID and interfaceID() method */
   DeclareInterfaceID(ISCT_RodEncoder, 1, 0);
 
-  /** convert all collections of RDO's in the current  list to vector of 32bit words */
-  virtual void fillROD(std::vector<uint32_t>& v, const uint32_t& robid, vRDOs& rdoVec) const = 0;
+  /** Destructor */
+  virtual ~ISCT_RodEncoder() = default;
 
+  /** Convert method */
+  virtual void fillROD(std::vector<uint32_t>& vec32Data, const uint32_t& robID, 
+                       const std::vector<const SCT_RDORawData*>& vecRDOs) const = 0;
 }; 
 
-#endif // SCT_RAWDATABYTESTREAM_ISCT_RODENCODER_H
+#endif // SCT_RAWDATABYTESTREAMCNV_ISCT_RODENCODER_H
diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTEventFlagWriter.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTEventFlagWriter.h
index f57597777e7078f29297c317f37dabc585d6ef9b..665085c3611e0592e1f8b95fc69d3dab4ddd1e1b 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTEventFlagWriter.h
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTEventFlagWriter.h
@@ -37,13 +37,13 @@ class SCTEventFlagWriter : public AthAlgorithm
   /** Execute */
   virtual StatusCode execute() override;
 
-  // Finalize empty, no need to override
-
  private:
 
+  /** Tool that keeps track of modules that give rise to errors in the bytestream. */
   ToolHandle<ISCT_ByteStreamErrorsTool> m_bsErrTool{this, "ErrorsTool", "SCT_ByteStreamErrorsTool", 
                                                     "Tool to retrieve SCT ByteStream Errors"};
 
+  /** Read handle for the xAOD event info. */
   SG::ReadHandleKey<xAOD::EventInfo> m_xAODEvtInfoKey{this, "xAODEventInfoKey", "EventInfo", 
                                                       "xAOD event info key"};
 };
diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.cxx b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.cxx
index 7cb06b753bc1b4da8a10cd0ed52c82a8b70dcca4..4690f307e95449428768c8f8d00861e0a5cfcf46 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.cxx
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamCnv.cxx
@@ -53,7 +53,7 @@ StatusCode SCTRawContByteStreamCnv::createRep(DataObject* pDataObject, IOpaqueAd
   // Get IDC for SCT Raw Data
   SCT_RDO_Container* sctRDOCont{nullptr};
   StoreGateSvc::fromStorable(pDataObject, sctRDOCont);
-  if (sctRDOCont==nullptr) {
+  if (sctRDOCont == nullptr) {
     m_log << MSG::ERROR << " Can not cast to SCTRawContainer " << endmsg;
     return StatusCode::FAILURE;
   }
diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h
index e6b87651cc7178519126bb4216b5a375d36edbdc..ef4d265a0e78a67bfbc527e86e2a1e52c84a12f4 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawContByteStreamTool.h
@@ -63,8 +63,8 @@ class SCTRawContByteStreamTool : public extends<AthAlgTool, ISCTRawContByteStrea
    * @param rawEvtWrite Data type for writing raw event.
    * @param log Object used to transmit messages and log errors.
    * */
-  StatusCode convert(const SCT_RDO_Container* sctRDOCont, 
-                     RawEventWrite* rawEvtWrite, MsgStream& log) const;
+  virtual StatusCode convert(const SCT_RDO_Container* sctRDOCont, 
+                             RawEventWrite* rawEvtWrite, MsgStream& log) const override;
   
  private: 
 
diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProvider.cxx b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProvider.cxx
index a36265ccb648d7883124dec467775371aced6a81..32acf01264bac71c6f5c060db9374cd35463c9ad 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProvider.cxx
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProvider.cxx
@@ -69,7 +69,7 @@ StatusCode SCTRawDataProvider::execute()
 
   SG::WriteHandle<SCT_RDO_Container> rdoContainer(m_rdoContainerKey);
   bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
-  if (!externalCacheRDO) {
+  if (not externalCacheRDO) {
     ATH_CHECK(rdoContainer.record (std::make_unique<SCT_RDO_Container>(m_sctID->wafer_hash_max())));
     ATH_MSG_DEBUG("Created container for " << m_sctID->wafer_hash_max());
   }
diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProvider.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProvider.h
index befb0bdaf1399744f65d6c7af17738e9fb39af1b..58d88c5d7f0c5fe72e410e4949f3f2048728ef64 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProvider.h
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProvider.h
@@ -55,57 +55,69 @@ class SCTRawDataProvider : public AthAlgorithm
   /** Execute */
   virtual StatusCode execute() override;
 
-  // Finalize empty, no need to override
-
  private:
 
+  /** Region Selector service for Athena. */
   ServiceHandle<IRegSelSvc> m_regionSelector;     
 
+  /** ROB Data Provider for accessing ROB data. */ 
   ServiceHandle<IROBDataProviderSvc> m_robDataProvider;
 
+  /** Tool to fill Collections of SCT RDO Containers. */
   ToolHandle<ISCTRawDataProviderTool> m_rawDataTool{this, 
                                                     "ProviderTool", 
                                                     "SCTRawDataProviderTool", 
                                                     "SCT  Raw Data Provider Tool"};
 
+  /** Providing mappings of online and offline identifiers and also serial numbers. */
   ToolHandle<ISCT_CablingTool> m_cabling{this, 
                                          "SCT_CablingTool", 
                                          "SCT_CablingTool", 
                                          "Tool to retrieve SCT Cabling"};
 
+  /** Identifier helper class for the SCT subdetector that creates compact Identifier objects and 
+      IdentifierHash or hash IDs. Also allows decoding of these IDs. */ 
   const SCT_ID* m_sctID; 
 
+  /** Boolean to determine if SCT Raw Data Provider should be run in RoI seeded mode. */
   BooleanProperty m_roiSeeded{this, "isRoI_Seeded", false, "Use RoI"};
 
+  /** Read handle for Trigger ROI descriptor collection. */
   SG::ReadHandleKey<TrigRoiDescriptorCollection> m_roiCollectionKey{this, 
                                                                     "RoIs",   
                                                                     "", 
                                                                     "RoIs to read in"};
 
+  /** Write handle for SCT RDO container. */
   SG::WriteHandleKey<SCT_RDO_Container> m_rdoContainerKey{this, 
                                                           "RDOKey", 
                                                           "SCT_RDOs", 
                                                           "SCT RDO key"};
 
+  /** Write handle for LVL 1 Inner Detector time collection. */
   SG::WriteHandleKey<InDetTimeCollection> m_lvl1CollectionKey{this, 
                                                               "LVL1IDKey", 
                                                               "SCT_LVL1ID", 
                                                               "SCT LVL1ID key"};
 
+  /** Write handle for BC ID Inner Detector time collection. */
   SG::WriteHandleKey<InDetTimeCollection> m_bcIDCollectionKey{this, 
                                                               "BCIDKey", 
                                                               "SCT_BCID", 
                                                               "SCT BCID key"};
 
+  /** Write handle for Inner Detector ByteStream error container. */
   SG::WriteHandleKey<InDetBSErrContainer> m_bsErrContainerKey{this, 
                                                               "ByteStreamErrContainer", 
                                                               "SCT_ByteStreamErrs", 
                                                               "SCT BS error key"};
 
+  /** Write handle for SCT ByteStream fraction container. */
   SG::WriteHandleKey<SCT_ByteStreamFractionContainer> m_bsFracContainerKey{this, 
                                                                            "ByteStreamFracContainer", 
                                                                            "SCT_ByteStreamFrac", 
                                                                            "SCT BS fraction key"};
+  /** Update handle for SCT RDO Cache. */
   SG::UpdateHandleKey<SCT_RDO_Cache> m_rdoContainerCacheKey;
 };
 
diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.cxx b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.cxx
index 1f1f07ad8290917042297ca8eecb2f5252824dc6..7b53401825cf5e3b2bdc271b616d3e19d8da59d9 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.cxx
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.cxx
@@ -11,9 +11,9 @@ using OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment;
 
 // Constructor
 
-SCTRawDataProviderTool::SCTRawDataProviderTool
-(const std::string& type, const std::string& name, const IInterface* parent)
-  : base_class(type, name, parent),
+SCTRawDataProviderTool::SCTRawDataProviderTool(const std::string& type, const std::string& name, 
+                                               const IInterface* parent) : 
+  base_class(type, name, parent),
   m_robIDSet{},
   m_decodeErrCount{0},
   m_mutex{}
@@ -66,7 +66,7 @@ StatusCode SCTRawDataProviderTool::convert(std::vector<const ROBFragment*>& vecR
     tmpROBIDSet.insert(robid);
 
     sc = m_decoder->fillCollection(*robFrag, rdoIDCont, errs, bsFracCont);
-    if (sc==StatusCode::FAILURE) {
+    if (sc == StatusCode::FAILURE) {
       if (m_decodeErrCount <= 100) {
         if (100 == m_decodeErrCount) {
           ATH_MSG_ERROR("Too many Problem with SCT Decoding messages, turning message off.");
@@ -83,7 +83,7 @@ StatusCode SCTRawDataProviderTool::convert(std::vector<const ROBFragment*>& vecR
   m_robIDSet.insert(tmpROBIDSet.begin(), tmpROBIDSet.end());
   m_mutex.unlock();
 
-  if (sc==StatusCode::FAILURE) {
+  if (sc == StatusCode::FAILURE) {
     ATH_MSG_ERROR("There was a problem with SCT ByteStream conversion");
     return sc;
   }
diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.h
index 7b6f0632ecb54a1af4ee477264472fa53345f6bb..107836740975032b4b87b485118b066795808454 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.h
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCTRawDataProviderTool.h
@@ -33,8 +33,7 @@ class SCTRawDataProviderTool : public extends<AthAlgTool, ISCTRawDataProviderToo
  public:
    
   /** Constructor */
-  SCTRawDataProviderTool(const std::string& type, const std::string& name,
-                         const IInterface* parent);
+  SCTRawDataProviderTool(const std::string& type, const std::string& name, const IInterface* parent);
 
   /** Destructor */
   virtual ~SCTRawDataProviderTool() = default;
@@ -42,8 +41,6 @@ class SCTRawDataProviderTool : public extends<AthAlgTool, ISCTRawDataProviderToo
   /** Initialize */
   virtual StatusCode initialize() override;
 
-  // finalize is empty, unnecessary to override
- 
   /** 
    * @brief Main decoding method.
    *
diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.cxx b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.cxx
index b62faf82df8c45ce9f7cccf367b677b39d71c1cd..f0308405fe4f5c4f594460f9e67a5a5940b15613 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.cxx
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.cxx
@@ -2,452 +2,456 @@
   Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
 */
 
-/** Implementation of SCT_RodEncoder class */
 #include "SCT_RodEncoder.h" 
 
-///InDet
-#include "InDetIdentifier/SCT_ID.h"
+#include "SCT_Cabling/ISCT_CablingTool.h"
 
-///Athena
-#include "Identifier/Identifier.h"
-#include "Identifier/IdentifierHash.h"
 #include "InDetRawData/SCT_RDORawData.h"
+#include "InDetIdentifier/SCT_ID.h"
 #include "InDetReadoutGeometry/SCT_DetectorManager.h"
 #include "InDetReadoutGeometry/SiDetectorElement.h"
 #include "InDetReadoutGeometry/SiDetectorElementCollection.h"
 
-namespace {
-  int rodLinkFromOnlineId(const uint32_t id) {
-    const SCT_OnlineId online{id};
-    const uint32_t f{online.fibre()};
-    const int formatter{static_cast<int>((f/12) & 0x7)};
-    const int linknb{static_cast<int>((f - (formatter*12)) & 0xF)};
-    const int rodlink{(formatter << 4) | linknb};
-    return rodlink;
+#include "Identifier/Identifier.h"
+#include "Identifier/IdentifierHash.h"
+
+namespace { // Anonymous namespace
+  int rodLinkFromOnlineID(const SCT_OnlineId onlineID)
+  {
+    const uint32_t fibre{onlineID.fibre()};
+    const int formatter{static_cast<int>((fibre/12) & 0x7)};
+    const int linkNum{static_cast<int>((fibre - (formatter*12)) & 0xF)};
+    const int rodLink{(formatter << 4) | linkNum};
+    return rodLink;
   } 
-  bool isOdd(const int someNumber){
+  bool isOdd(const int someNumber)
+  {
     return static_cast<bool>(someNumber & 1);
   }
  
-  bool isEven(const int someNumber) {
+  bool isEven(const int someNumber) 
+  {
     return not isOdd(someNumber);
   }
  
-  bool swappedCable(const int moduleSide, const int linkNumber) {
+  bool swappedCable(const int moduleSide, const int linkNumber) 
+  {
     return isOdd(linkNumber) ? (moduleSide==0) : (moduleSide==1);
   }
-}//end of anon namespace
+} // End of anonymous namespace
 
+// Constructor
 
-SCT_RodEncoder::SCT_RodEncoder
-(const std::string& type, const std::string& name, const IInterface* parent) : 
+SCT_RodEncoder::SCT_RodEncoder(const std::string& type, const std::string& name, const IInterface* parent) : 
   base_class(type, name, parent),
-  m_sct_id{nullptr},
-  m_swapModuleId{} {
-  }
+  m_sctID{nullptr},
+  m_swapModuleID{} 
+{
+}
+
+// Initialize
 
-StatusCode SCT_RodEncoder::initialize() {
-  //prob. dont need this next line now:
-  //ATH_CHECK( AlgTool::initialize());
+StatusCode SCT_RodEncoder::initialize() 
+{
   ATH_MSG_DEBUG("SCT_RodEncoder::initialize()");
   
-  /** Retrieve cabling tool */
+  // Retrieve cabling tool
   ATH_CHECK(m_cabling.retrieve());
   ATH_MSG_DEBUG("Retrieved tool " << m_cabling);
 
-  ATH_CHECK(detStore()->retrieve(m_sct_id, "SCT_ID"));
-  ATH_CHECK(m_bsErrs.retrieve());
+  ATH_CHECK(detStore()->retrieve(m_sctID, "SCT_ID"));
+  ATH_CHECK(m_bsErrTool.retrieve());
 
   // See if strip numbers go from 0 to 767 or vice versa for all the wafers.
   // swapPhiReadoutDirection will not change during a run.
   // Since this is access to SiDetectorElement during initialization,
   // condition object of SiDetectorElementCollection is not accessible.
   // SCT_DetectorManager has to be used.
-  const InDetDD::SCT_DetectorManager* detManager{nullptr};
-  ATH_CHECK(detStore()->retrieve(detManager, "SCT"));
-  const InDetDD::SiDetectorElementCollection* elements{detManager->getDetectorElementCollection()};
-  for (const InDetDD::SiDetectorElement* element: *elements) {
-    if (element->swapPhiReadoutDirection()) {
-      m_swapModuleId.insert(element->identify());
+  const InDetDD::SCT_DetectorManager* sctDetManager{nullptr};
+  ATH_CHECK(detStore()->retrieve(sctDetManager, "SCT"));
+
+  const InDetDD::SiDetectorElementCollection* sctDetElementColl{sctDetManager->getDetectorElementCollection()};
+  for (auto sctDetElement : *sctDetElementColl) {
+    if (sctDetElement->swapPhiReadoutDirection()) {
+      m_swapModuleID.insert(sctDetElement->identify());
     }
   }
 
   return StatusCode::SUCCESS;
 }
 
-StatusCode SCT_RodEncoder::finalize() {
+// Finalize
+
+StatusCode SCT_RodEncoder::finalize() 
+{
   return StatusCode::SUCCESS;
 }
 
-///=========================================================================
-///  fillROD convert SCT RDO to a vector of 32bit words
-///=========================================================================
-
-void SCT_RodEncoder::fillROD(std::vector<uint32_t>& v32rod, const uint32_t& robid, 
-                             vRDOs_t& rdoVec) const {
+// fillROD method
+
+void SCT_RodEncoder::fillROD(std::vector<uint32_t>& vec32Data, const uint32_t& robID, 
+                             const std::vector<const SCT_RDORawData*>& vecRDOs) const 
+{
+  // Retrieve errors from SCT_ByteStreamErrorsSvc
+  const std::set<IdentifierHash>* timeOutErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::TimeOutError)};
+  const std::set<IdentifierHash>* lvl1IDErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::LVL1IDError)};
+  const std::set<IdentifierHash>* bcIDErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::BCIDError)};
+  const std::set<IdentifierHash>* preambleErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::PreambleError)};
+  const std::set<IdentifierHash>* formatterErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::FormatterError)};
+  const std::set<IdentifierHash>* trailerErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::TrailerError)};
+  const std::set<IdentifierHash>* headerTrailerErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::HeaderTrailerLimitError)};
+  const std::set<IdentifierHash>* trailerOverflowErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::TrailerOverflowError)};
+  const std::set<IdentifierHash>* abcdErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::ABCDError)};
+  const std::set<IdentifierHash>* rawErrors{m_bsErrTool->getErrorSet(SCT_ByteStreamErrors::RawError)};
+
+  std::vector<uint16_t> vec16Data;
+  
+  // Loop over errors here - just add headers (w/ errors), trailers (w/errors), and raw and abcd errors
+  addHeadersWithErrors(robID, timeOutErrors, TIMEOUT_ERR, vec16Data);
+  addHeadersWithErrors(robID, lvl1IDErrors, L1_ERR, vec16Data);
+  addHeadersWithErrors(robID, bcIDErrors, BCID_ERR, vec16Data);
+  addHeadersWithErrors(robID, preambleErrors, PREAMBLE_ERR, vec16Data);
+  addHeadersWithErrors(robID, formatterErrors, FORMATTER_ERR, vec16Data);
+  
+  addTrailersWithErrors(robID, trailerErrors, TRAILER_ERR, vec16Data);
+  addTrailersWithErrors(robID, headerTrailerErrors, HEADER_TRAILER_ERR, vec16Data);
+  addTrailersWithErrors(robID, trailerOverflowErrors, TRAILER_OVFLW_ERR, vec16Data);
   
-  /** retrieve errors from SCT_ByteStreamErrorsSvc */
-
-  const std::set<IdentifierHash>* timeOutErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::TimeOutError)};
-  const std::set<IdentifierHash>* l1idErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::LVL1IDError)};
-  const std::set<IdentifierHash>* bcidErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::BCIDError)};
-  const std::set<IdentifierHash>* preambleErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::PreambleError)};
-  const std::set<IdentifierHash>* formatterErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::FormatterError)};
-  const std::set<IdentifierHash>* trailerErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::TrailerError)};
-  const std::set<IdentifierHash>* headertrailerErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::HeaderTrailerLimitError)};
-  const std::set<IdentifierHash>* traileroverflowErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::TrailerOverflowError)};
-  const std::set<IdentifierHash>* rawErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::RawError)};
-  const std::set<IdentifierHash>* abcdErrors{m_bsErrs->getErrorSet(SCT_ByteStreamErrors::ABCDError)};
-
-  std::vector<int> vtbin;
-  std::vector<uint16_t> v16data;
-  int strip1{0};
-  int theTimeBin{0};
-  int groupsize{0};
+  addSpecificErrors(robID, abcdErrors, ABCD_ERR, vec16Data);
+  addSpecificErrors(robID, rawErrors, RAWDATA_ERR, vec16Data);
   
-  /** loop over errors here - just add headers (w/ errors), trailers (w/errors), 
-   * and raw and abcd errors */
-
-  addHeadersWithErrors(robid, timeOutErrors, TIMEOUT_ERR, v16data);
-  addHeadersWithErrors(robid, l1idErrors, L1_ERR, v16data);
-  addHeadersWithErrors(robid, bcidErrors, BCID_ERR, v16data);
-  addHeadersWithErrors(robid, preambleErrors, PREAMBLE_ERR, v16data);
-  addHeadersWithErrors(robid, formatterErrors, FORMATTER_ERR, v16data);
-  //
-  addTrailersWithErrors(robid, trailerErrors, TRAILER_ERR, v16data);
-  addTrailersWithErrors(robid, headertrailerErrors, HEADER_TRAILER_ERR, v16data);
-  addTrailersWithErrors(robid, traileroverflowErrors, TRAILER_OVFLW_ERR, v16data);
-  //
-  addSpecificErrors(robid, abcdErrors, ABCD_ERR, v16data);
-  addSpecificErrors(robid, rawErrors, RAWDATA_ERR, v16data);
+  std::vector<bool> vec_isDuplicated(vecRDOs.size(), false);
   
-  std::vector<bool> v_isDuplicated(rdoVec.size(), false);
-  for (unsigned int iRdo{0}; iRdo<rdoVec.size(); iRdo++) {
-    const RDO* rawdata{rdoVec.at(iRdo)};
-    if (rawdata==nullptr) {
+  // Loop over RDOs to check for duplicates and fill vec_isDuplicated vector
+  for (unsigned int iRDO1{0}; iRDO1<vecRDOs.size(); iRDO1++) {
+    const SCT_RDORawData* rdo1{vecRDOs.at(iRDO1)};
+    if (rdo1 == nullptr) {
       ATH_MSG_ERROR("RDO pointer is NULL. skipping this hit.");
-      v_isDuplicated.at(iRdo) = true;
+      vec_isDuplicated.at(iRDO1) = true;
       continue;
     }
 
     // Check if there is another RDO with the same first strip
-    for (unsigned int iRdo2{0}; iRdo2<iRdo; iRdo2++) {
-      const RDO* rawdata2{rdoVec.at(iRdo2)};
-      if (v_isDuplicated.at(iRdo2)) continue;
+    for (unsigned int iRDO2{0}; iRDO2<iRDO1; iRDO2++) {
+      const SCT_RDORawData* rdo2{vecRDOs.at(iRDO2)};
+      if (vec_isDuplicated.at(iRDO2)) continue;
 
-      if (rawdata->identify()==rawdata2->identify()) {
+      if (rdo1->identify() == rdo2->identify()) {
         // Keep RDO with larger cluster size. If cluster sizes are the same, keep the first one.
-        if (rawdata->getGroupSize()>=rawdata2->getGroupSize()) {
-          v_isDuplicated.at(iRdo2) = true;
-        } else {
-          v_isDuplicated.at(iRdo)  = true;
+        if (rdo1->getGroupSize() >= rdo2->getGroupSize()) {
+          vec_isDuplicated.at(iRDO2) = true;
+        } 
+        else {
+          vec_isDuplicated.at(iRDO1)  = true;
         }
         break;
       }
     }
   }
 
+  std::vector<int> vecTimeBins;
+  int strip{0};
+  int timeBin{0};
+  int groupSize{0};
+
   uint32_t lastHeader{0};
-  bool firstInRod{true};
+  bool firstInROD{true};
   uint16_t lastTrailer{0};
-  for (unsigned int iRdo{0}; iRdo<rdoVec.size(); iRdo++) {
-    const RDO* rawdata{rdoVec.at(iRdo)};
-    if (v_isDuplicated.at(iRdo)) continue;
 
-    const uint16_t header{this->getHeaderUsingRDO(rawdata)};
+  // Loop over RDOs to decode to 16 bit words
+  for (unsigned int iRDO{0}; iRDO<vecRDOs.size(); iRDO++) {
+    const SCT_RDORawData* rdo{vecRDOs.at(iRDO)};
+    if (vec_isDuplicated.at(iRDO)) continue;
+
+    const uint16_t header{this->getHeaderUsingRDO(rdo)};
     if (header != lastHeader) {
-      if (! firstInRod) {
-        v16data.push_back(lastTrailer);
+      if (not firstInROD) {
+        vec16Data.push_back(lastTrailer);
       }
-      firstInRod = false;
-      v16data.push_back(header);
+      firstInROD = false;
+      vec16Data.push_back(header);
       lastHeader = header;
       lastTrailer = getTrailer(0);
     }
-    if (m_condensed.value()) { /** Condensed mode */
-      strip1 = strip(rawdata);
-      groupsize = groupSize(rawdata);
-      if (groupsize == 1) { /** For single hit */
-        const int gSize{1};
-        const int strip2{strip1};
-        encodeData(vtbin, v16data, rawdata, gSize, strip2);
+    if (m_condensed.value()) { // Condensed mode
+      strip = getStrip(rdo);
+      groupSize = rdo->getGroupSize();
+      if (groupSize == 1) { // For single hit
+        const int constGroupSize{1};
+        const int constStrip{strip};
+        encodeData(vecTimeBins, vec16Data, rdo, constGroupSize, constStrip);
       }
-      /** Sim rdo could have groupe size > 1 then I need to split 
-       * them 2 by 2 to built the condensed BS data */
-      else { /** Encoding in condensed BS paired data from groupe size > 1 */
-        const int chipFirst{strip1/128};
-        const int chipLast{(strip1+groupsize-1)/128};
+      // Sim RDO could have groupe size > 1, then they are split 2 by 2 to built the condensed BS data.
+      else { // Encoding in condensed BS paired data from groupe size > 1.
+        const int chipFirst{strip/128};
+        const int chipLast{(strip+groupSize-1)/128};
 
         for (int chip{chipFirst}; chip<=chipLast; chip++) {
-          int tmpGroupsize = 0;
-          if (chipFirst==chipLast) tmpGroupsize = groupsize; // In case of one chip
-          else if (chip==chipLast) tmpGroupsize = strip1+groupsize-chip*128; // In case of last chip
-          else if (chip==chipFirst) tmpGroupsize = (chip+1)*128-strip1; // In case of first chip
-          else tmpGroupsize = 128; // In case of middle chip
-          const int tmpStrip1{chip==chipFirst ? strip1 : 128*chip};
-
-          const int n_pairedRdo{tmpGroupsize/2};
-          for (int i =0; i<n_pairedRdo; i++) {
-            const int gSize{2};
-            const int strip2{tmpStrip1+ (2*i)};
-            encodeData(vtbin, v16data, rawdata, gSize, strip2);
+          int tmpGroupSize = 0;
+          if (chipFirst == chipLast) tmpGroupSize = groupSize; // In case of one chip
+          else if (chip == chipLast) tmpGroupSize = strip+groupSize-chip*128; // In case of last chip
+          else if (chip == chipFirst) tmpGroupSize = (chip+1)*128-strip; // In case of first chip
+          else tmpGroupSize = 128; // In case of middle chip
+          const int tmpStrip1{chip==chipFirst ? strip : 128*chip};
+
+          const int numPairedRDO{tmpGroupSize/2};
+          for (int i =0; i<numPairedRDO; i++) {
+            const int constGroupSize{2};
+            const int constStrip{tmpStrip1+ (2*i)};
+            encodeData(vecTimeBins, vec16Data, rdo, constGroupSize, constStrip);
           } 
-          if ((tmpGroupsize != 0) and isOdd(tmpGroupsize)) {/** The last hit from a cluster with odd group size */
-            const int gSize{1};
-            const int strip2{tmpStrip1+ (tmpGroupsize - 1)};
-            encodeData(vtbin, v16data, rawdata, gSize, strip2);
+          if ((tmpGroupSize != 0) and isOdd(tmpGroupSize)) {// The last hit from a cluster with odd group size
+            const int constGroupSize{1};
+            const int constStrip{tmpStrip1+ (tmpGroupSize - 1)};
+            encodeData(vecTimeBins, vec16Data, rdo, constGroupSize, constStrip);
           }  
         }
-
       }  
       
-    } /** end of condensed Mode */
+    } // End of Condensed mode
     
-    else {/** Expanded mode */
+    else { // Expanded mode
+      vecTimeBins.clear();
+      const SCT_RDORawData* rdo{vecRDOs.at(iRDO)};
+      strip = getStrip(rdo);
+      timeBin = getTimeBin(rdo);
+      groupSize = rdo->getGroupSize();
       
-      vtbin.clear();
-      const RDO* rawdata{rdoVec.at(iRdo)};
-      strip1 = strip(rawdata);
-      theTimeBin = tbin(rawdata);
-      groupsize = groupSize(rawdata);
-      
-      for (int t{0}; t < groupsize; t++) {
-        vtbin.push_back(theTimeBin);
-        strip1++;
+      for (int t{0}; t < groupSize; t++) {
+        vecTimeBins.push_back(timeBin);
+        strip++;
       }
-      const int strip2{strip(rawdata)};
-      const int gSize{groupSize(rawdata)};
-      encodeData(vtbin, v16data, rawdata, gSize, strip2);
+      const int constStrip{getStrip(rdo)};
+      const int constGroupSize{rdo->getGroupSize()};
+      encodeData(vecTimeBins, vec16Data, rdo, constGroupSize, constStrip);
       
-    }  // End of (else) Expanded
-  } //end of RDO loop
-  if (!firstInRod and lastTrailer!=0) {
-    v16data.push_back(lastTrailer);
+    }  // End of Expanded mode
+  } // End of RDO decode loop
+
+  if ((not firstInROD) and (lastTrailer != 0)) {
+    vec16Data.push_back(lastTrailer);
   }
-  /** 16 bits TO 32 bits and pack into 32 bit vectors */
-  packFragments(v16data,v32rod);
   
-  return;
+  // 16 bits TO 32 bits and pack into 32 bit vectors
+  packFragments(vec16Data,vec32Data);
   
-} // end of fillROD(...)
-
-void SCT_RodEncoder::addHeadersWithErrors(const uint32_t& robid, const std::set<IdentifierHash>* errors, const ErrorWords& errType, std::vector<uint16_t>& v16data) const {
-  for (const IdentifierHash& linkHash: *errors) {
-    const uint32_t errRobId{m_cabling->getRobIdFromHash(linkHash)};
-    if (errRobId == robid) {
-      const uint16_t header{getHeaderUsingHash(linkHash, errType)};
-      v16data.push_back(header);
-      const uint16_t trailer{getTrailer(NULL_TRAILER_ERR)};
-      v16data.push_back(trailer);
-    }
-  }
-} 
-
-//
-void SCT_RodEncoder::addTrailersWithErrors(const uint32_t& robid, const std::set<IdentifierHash>* errors, const ErrorWords& errType, std::vector<uint16_t>& v16data) const {
-  for (const IdentifierHash& linkHash: *errors) {
-    const uint32_t errRobId{m_cabling->getRobIdFromHash(linkHash)};
-    if (errRobId == robid) {
-      const uint16_t header{getHeaderUsingHash(linkHash, NULL_HEADER_ERR)};
-      const uint16_t trailer{getTrailer(errType)};
-      v16data.push_back(header);
-      v16data.push_back(trailer);
-    }
-  }
-}
-
-void SCT_RodEncoder::addSpecificErrors(const uint32_t& robid, const std::set<IdentifierHash>* errors, const ErrorWords& errType, std::vector<uint16_t>& v16data) const {
-  for (const IdentifierHash& linkHash: *errors) {
-    const uint32_t errRobId{m_cabling->getRobIdFromHash(linkHash)};
-    if (errRobId == robid) {
-      const uint16_t header{getHeaderUsingHash(linkHash, NULL_HEADER_ERR)};
-      const uint16_t trailer{getTrailer(NULL_TRAILER_ERR)};
-      v16data.push_back(header);
-      v16data.push_back(errType);
-      v16data.push_back(trailer);
-    }
-  }
+  return;
 }
 
-///=========================================================================
-/// Encode Data function
-///========================================================================= 
+// encodeData method
 
-void SCT_RodEncoder::encodeData(std::vector<int>& vtbin, std::vector<uint16_t>& v16, const RDO *rdo, const int& gSize, const int& strip2) const {
-  
-  ///-------------------------------------------------------------------------------------
-  /// Check if the strip has to be swapped (swap phi readout direction)
-  ///-------------------------------------------------------------------------------------
-  
+void SCT_RodEncoder::encodeData(const std::vector<int>& vecTimeBins, std::vector<uint16_t>& vec16Words, 
+                                const SCT_RDORawData* rdo, const int& groupSize, const int& strip) const 
+{
   const int encodedSide{side(rdo) << 14};
   
-  const Identifier idColl{offlineId(rdo)};
-  int strip1{strip2};
-  if (m_swapModuleId.find(idColl)!= m_swapModuleId.end()) {
-    strip1= 767 - strip1;
-    strip1= strip1-(gSize-1);
+  const Identifier idColl{offlineID(rdo)};
+  int tmpStrip{strip};
+  if (m_swapModuleID.find(idColl) != m_swapModuleID.end()) { // Check if the strip has to be swapped (swap phi readout direction)
+    tmpStrip= 767 - tmpStrip;
+    tmpStrip= tmpStrip-(groupSize-1);
   }
   
-  const int chipNb{((strip1/128) & 0x7) << 11};
-  const int clustBaseAddr{((strip1-(chipNb*128)) & 0x7F) << 4};
-  int theTimeBin{0};
+  const int chipNum{((tmpStrip/128) & 0x7) << 11};
+  const int clustBaseAddr{((tmpStrip-(chipNum*128)) & 0x7F) << 4};
+
+  int timeBin{0};
   int firstHitErr{0 << 2};
   int secondHitErr{0 << 3};
   
   const SCT3_RawData* rdoCosmic{dynamic_cast<const SCT3_RawData*>(rdo)};
   if (rdoCosmic != nullptr) {
-    theTimeBin = tbin(rdoCosmic);
+    timeBin = getTimeBin(rdoCosmic);
     firstHitErr = ((rdoCosmic)->FirstHitError()) << 2;
     secondHitErr = ((rdoCosmic)->SecondHitError()) << 3;
   }
   
-  ///-------------------------------------------------------------------------------------
-  /// Condensed
-  ///-------------------------------------------------------------------------------------
-  if (m_condensed.value()) {/** single Hit on condensed Mode */
-    if (gSize == 1) {/** Group size = 1 */
-      const uint16_t HitCondSingle{static_cast<uint16_t>(0x8000 | encodedSide | chipNb | clustBaseAddr | firstHitErr)};
-      v16.push_back(HitCondSingle);
-    } else if (gSize == 2) {/** paired strip Hits on condensed Mode */
-      const uint16_t HitCondPaired{static_cast<uint16_t>(0x8001 | encodedSide | chipNb | clustBaseAddr | secondHitErr | firstHitErr)};
-      v16.push_back(HitCondPaired);
+  if (m_condensed.value()) { // Condensed mode
+    if (groupSize == 1) { // For single hit
+      const uint16_t hitCondSingle{static_cast<uint16_t>(0x8000 | encodedSide | chipNum | clustBaseAddr | firstHitErr)};
+      vec16Words.push_back(hitCondSingle);
+    } 
+    else if (groupSize == 2) { //  For paired strip Hits
+      const uint16_t hitCondPaired{static_cast<uint16_t>(0x8001 | encodedSide | chipNum | clustBaseAddr | secondHitErr | firstHitErr)};
+      vec16Words.push_back(hitCondPaired);
     }    
-  }  /// end of condensed
-  ///-------------------------------------------------------------------------------------
-  /// Expanded
-  ///-------------------------------------------------------------------------------------
-  else {
-    const int nEven{static_cast<int>((vtbin.size() - 1)/2)};
-    /** First hit */
-    const uint16_t HitExpFirst{static_cast<uint16_t>(0x8000 | encodedSide | chipNb | clustBaseAddr | theTimeBin)};
-    v16.push_back(HitExpFirst);
-    /** Even consecutive strips to the first one 1DDD 1st consec strip 1DDD 2nd consec strip */
-    for (int i=1; i<=nEven; i++) {
-      const uint16_t HitExpEven{static_cast<uint16_t>(0x8088 | ((vtbin[(2*i-1)] & 0xF) << 4) | (vtbin[2*i] & 0xF))};
-      v16.push_back(HitExpEven);
+  } // End of Condensed mode
+  
+  else { // Expanded mode
+    const int numEven{static_cast<int>((vecTimeBins.size() - 1)/2)};
+
+    // First hit
+    const uint16_t hitExpFirst{static_cast<uint16_t>(0x8000 | encodedSide | chipNum | clustBaseAddr | timeBin)};
+    vec16Words.push_back(hitExpFirst);
+
+    // Even consecutive strips to the first one 1DDD 1st consec strip 1DDD 2nd consec strip
+    for (int i=1; i<=numEven; i++) {
+      const uint16_t hitExpEven{static_cast<uint16_t>(0x8088 | ((vecTimeBins[(2*i-1)] & 0xF) << 4) | (vecTimeBins[2*i] & 0xF))};
+      vec16Words.push_back(hitExpEven);
     }
-    /** Last bin of the Odd next hits */
-    if ((not vtbin.empty() ) and isEven(vtbin.size())) {
-      const uint16_t HitExpLast{static_cast<uint16_t>(0x8008 | (vtbin[vtbin.size()-1] & 0xF))};
-      v16.push_back(HitExpLast);
+    // Last bin of the Odd next hits
+    if ((not vecTimeBins.empty()) and isEven(vecTimeBins.size())) {
+      const uint16_t hitExpLast{static_cast<uint16_t>(0x8008 | (vecTimeBins[vecTimeBins.size()-1] & 0xF))};
+      vec16Words.push_back(hitExpLast);
     }  
-  } /** end of expanded */
+  } // End of Expanded mode
   
   return;
-} /** end of encodeData */
-
-///=========================================================================
-/// Converting the 16 bit vector v16 to 32 bit words v32
-///=========================================================================
-void SCT_RodEncoder::packFragments(std::vector<uint16_t>& v16, std::vector<uint32_t>& v32) const {
-  int n16words{static_cast<int>(v16.size())};
-  if (isOdd(n16words)) {
-    /** just add an additional 16bit words to make even size v16 to in the 32 bits word 0x40004000 */
-    v16.push_back(0x4000);
-    n16words++;
+}
+
+// packFragments function
+
+void SCT_RodEncoder::packFragments(std::vector<uint16_t>& vec16Words, 
+                                   std::vector<uint32_t>& vec32Words) const 
+{
+  int num16Words{static_cast<int>(vec16Words.size())};
+  if (isOdd(num16Words)) {
+    // Just add an additional 16bit words to make even size v16 to in the 32 bits word 0x40004000
+    vec16Words.push_back(0x4000);
+    num16Words++;
   }
-  /** now merge 2 consecutive 16 bit words in 32 bit words */
-  const unsigned short int nWords{2};
-  const unsigned short int position[nWords]{0, 16};
-  unsigned short int v16words[nWords]{0, 0};
-  for (int i{0}; i<n16words; i += nWords) {
-    v16words[i%nWords]     = v16[i+1];
-    v16words[(i+1)%nWords] = v16[i];
-    const uint32_t v32word{set32bits(v16words, position, nWords)};
-    v32.push_back(v32word);
+  // Now merge 2 consecutive 16 bit words in 32 bit words
+  const unsigned short int numWords{2};
+  const unsigned short int position[numWords]{0, 16};
+  unsigned short int arr16Words[numWords]{0, 0};
+  for (int i{0}; i<num16Words; i += numWords) {
+    arr16Words[i%numWords]     = vec16Words[i+1];
+    arr16Words[(i+1)%numWords] = vec16Words[i];
+    const uint32_t uint32Word{set32Bits(arr16Words, position, numWords)};
+    vec32Words.push_back(uint32Word);
 #ifdef SCT_DEBUG
-    ATH_MSG_INFO("SCT encoder -> PackFragments: Output rod 0x"<<std::hex<<v32word<<std::dec);
+    ATH_MSG_INFO("SCT encoder -> PackFragments: Output rod 0x"<<std::hex<<uint32Word<<std::dec);
 #endif
   }
   
   return;
 }
 
-///=========================================================================
-/// set the 16 bit word v16 to 32 bit words v32
-///=========================================================================
-
-uint32_t SCT_RodEncoder::set32bits(const unsigned short int* v16, const unsigned short int* pos, const unsigned short int& n) const {
-  uint32_t v32{0};
-  uint32_t p{0};
-  uint32_t v{0};
-  for (uint16_t i{0}; i<n; i++) {
-    v = static_cast<uint32_t>(*(v16+i));
-    p = static_cast<uint32_t>(*(pos+i));
-    v32 |= (v<<p);
+// set32Bits function
+
+uint32_t SCT_RodEncoder::set32Bits(const unsigned short int* arr16Words, 
+                                   const unsigned short int* position, 
+                                   const unsigned short int& numWords) const 
+{
+  uint32_t uint32Word{0};
+  uint32_t pos{0};
+  uint32_t uint16Word{0};
+  for (uint16_t i{0}; i<numWords; i++) {
+    uint16Word = static_cast<uint32_t>(*(arr16Words+i));
+    pos = static_cast<uint32_t>(*(position+i));
+    uint32Word |= (uint16Word<<pos);
   } 
-  return v32;
+  return uint32Word;
 }
 
-///=========================================================================
-/// Link and Side Numbers 
-///=========================================================================
-/** Strip number */ 
-int SCT_RodEncoder::strip(const RDO* rdo) const {
-  const Identifier rdoId{rdo->identify()};
-  return m_sct_id->strip(rdoId);
+// Get RDO info functions
+
+int SCT_RodEncoder::getStrip(const SCT_RDORawData* rdo) const 
+{
+  const Identifier rdoID{rdo->identify()};
+  return m_sctID->strip(rdoID);
 }
 
-/** RDO ID */
-Identifier SCT_RodEncoder::offlineId(const RDO* rdo) const {
+Identifier SCT_RodEncoder::offlineID(const SCT_RDORawData* rdo) const 
+{
   const Identifier rdoId{rdo->identify()};
-  return m_sct_id->wafer_id(rdoId);
+  return m_sctID->wafer_id(rdoId);
 }
 
-/** ROD online ID */
-uint32_t SCT_RodEncoder::onlineId(const RDO* rdo) const {
-  const Identifier waferId{offlineId(rdo)};
-  const IdentifierHash offlineIdHash{m_sct_id->wafer_hash(waferId)};
-  const uint32_t thisOnlineId{m_cabling->getOnlineIdFromHash(offlineIdHash)};
-  return thisOnlineId;
+uint32_t SCT_RodEncoder::onlineID(const SCT_RDORawData* rdo) const 
+{
+  const Identifier waferID{offlineID(rdo)};
+  const IdentifierHash offlineIDHash{m_sctID->wafer_hash(waferID)};
+  return static_cast<const uint32_t>(m_cabling->getOnlineIdFromHash(offlineIDHash));
 }
 
-/** ROD Link Number In the ROD header data */
-int SCT_RodEncoder::rodLink(const RDO* rdo) const {
-  return rodLinkFromOnlineId(onlineId(rdo));
+int SCT_RodEncoder::getRODLink(const SCT_RDORawData* rdo) const 
+{
+  return rodLinkFromOnlineID(onlineID(rdo));
 }
 
-/** Side Info */
-int SCT_RodEncoder::side(const RDO* rdo) const {
-  const Identifier rdoId{rdo->identify()};
-  int s{m_sct_id->side(rdoId)};
-  /** see if we need to swap sides due to cabling weirdness */
-  const int linknb{rodLink(rdo) & 0xF};
-  if (swappedCable(s,linknb)) s = 1-s;
-  return s;
+int SCT_RodEncoder::side(const SCT_RDORawData* rdo) const 
+{
+  const Identifier rdoID{rdo->identify()};
+  int sctSide{m_sctID->side(rdoID)};
+  // see if we need to swap sides due to cabling weirdness
+  const int linkNum{getRODLink(rdo) & 0xF};
+  if (swappedCable(sctSide,linkNum)) sctSide = 1-sctSide;
+  return sctSide;
 }
 
-/** Time Bin Info */
-int SCT_RodEncoder::tbin(const RDO* rdo) const {
-  int theTimeBin{0};
+int SCT_RodEncoder::getTimeBin(const SCT_RDORawData* rdo) const 
+{
+  int timeBin{0};
   const SCT3_RawData* rdoCosmic{dynamic_cast<const SCT3_RawData*>(rdo)};
-  if (rdoCosmic != 0) theTimeBin = rdoCosmic->getTimeBin();
-  return theTimeBin;
+  if (rdoCosmic != 0) timeBin = rdoCosmic->getTimeBin();
+  return timeBin;
 }
 
-///-------------------------------------------------------------------------------------
-/// Link header
-///-------------------------------------------------------------------------------------
+// Get headers and trailer functions
+
+uint16_t SCT_RodEncoder::getHeaderUsingRDO(const SCT_RDORawData* rdo) const 
+{
+  const int rodLink{getRODLink(rdo)};
+  const uint16_t linkHeader{static_cast<uint16_t>(0x2000 | (m_condensed.value() << 8) | rodLink)};
+  return linkHeader;
+}
 
-uint16_t 
-SCT_RodEncoder::getHeaderUsingRDO(const RDO* rdo) const {
-  const int rodlink{rodLink(rdo)};
-  const uint16_t LinkHeader{static_cast<uint16_t>(0x2000 | (m_condensed.value() << 8) | rodlink)};
-  return LinkHeader;
+uint16_t SCT_RodEncoder::getHeaderUsingHash(const IdentifierHash& linkHash, const int& errorWord) const 
+{
+  const int rodLink{rodLinkFromOnlineID(m_cabling->getOnlineIdFromHash(linkHash))};
+  const uint16_t linkHeader{static_cast<uint16_t>(0x2000 | errorWord | (m_condensed.value() << 8) | rodLink)};
+  return linkHeader;
 }
 
-uint16_t 
-SCT_RodEncoder::getHeaderUsingHash(const IdentifierHash& linkHash, const int& errorWord) const {
-  const int rodlink{rodLinkFromOnlineId(m_cabling->getOnlineIdFromHash(linkHash))};
-  const uint16_t LinkHeader{static_cast<uint16_t>(0x2000 | errorWord | (m_condensed.value() << 8) | rodlink)};
-  return LinkHeader;
+uint16_t SCT_RodEncoder::getTrailer(const int& errorWord) const 
+{
+  const uint16_t linkTrailer{static_cast<uint16_t>(0x4000 | errorWord)};
+  return linkTrailer;
 }
 
-///-------------------------------------------------------------------------------------
-/// Link trailer
-///-------------------------------------------------------------------------------------
-uint16_t 
-SCT_RodEncoder::getTrailer(const int& errorword) const {
-  const uint16_t LinkTrailer{static_cast<uint16_t>(0x4000 | errorword)};
-  return LinkTrailer;
+// Add errors functions
+
+void SCT_RodEncoder::addHeadersWithErrors(const uint32_t& robID, const std::set<IdentifierHash>* errors, 
+                                          const ErrorWords& errType, std::vector<uint16_t>& vec16Data) const 
+{
+  for (const IdentifierHash& linkHash: *errors) {
+    const uint32_t errROBID{m_cabling->getRobIdFromHash(linkHash)};
+    if (errROBID == robID) {
+      const uint16_t header{getHeaderUsingHash(linkHash, errType)};
+      vec16Data.push_back(header);
+      const uint16_t trailer{getTrailer(NULL_TRAILER_ERR)};
+      vec16Data.push_back(trailer);
+    }
+  }
+} 
+
+//
+void SCT_RodEncoder::addTrailersWithErrors(const uint32_t& robID, const std::set<IdentifierHash>* errors, 
+                                           const ErrorWords& errType, std::vector<uint16_t>& vec16Data) const 
+{
+  for (const IdentifierHash& linkHash: *errors) {
+    const uint32_t errROBID{m_cabling->getRobIdFromHash(linkHash)};
+    if (errROBID == robID) {
+      const uint16_t header{getHeaderUsingHash(linkHash, NULL_HEADER_ERR)};
+      const uint16_t trailer{getTrailer(errType)};
+      vec16Data.push_back(header);
+      vec16Data.push_back(trailer);
+    }
+  }
+}
+
+void SCT_RodEncoder::addSpecificErrors(const uint32_t& robID, const std::set<IdentifierHash>* errors, 
+                                       const ErrorWords& errType, std::vector<uint16_t>& vec16Data) const 
+{
+  for (const IdentifierHash& linkHash: *errors) {
+    const uint32_t errROBID{m_cabling->getRobIdFromHash(linkHash)};
+    if (errROBID == robID) {
+      const uint16_t header{getHeaderUsingHash(linkHash, NULL_HEADER_ERR)};
+      const uint16_t trailer{getTrailer(NULL_TRAILER_ERR)};
+      vec16Data.push_back(header);
+      vec16Data.push_back(errType);
+      vec16Data.push_back(trailer);
+    }
+  }
 }
diff --git a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.h b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.h
index 882627cd89d3af261ffef84ca823b0ba398d8bd8..97795431a92d0e3a751953f4ab6190aa6ab47d69 100644
--- a/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.h
+++ b/InnerDetector/InDetEventCnv/SCT_RawDataByteStreamCnv/src/SCT_RodEncoder.h
@@ -3,109 +3,79 @@
 */
 
 /**
- *      @header file for SCT_RodEncoder Class
- *      This class provides conversion from SCT RDO to ROD format ByteStream.
- *      @date 21/06/07:  SCT_RodEncoder turned into An AlgTool 
- *      @author: Nick Barlow nbarlow@mail.cern.ch, Kondo.Gnanvo@cern.ch
- *  
+ * @file SCT_RodEncoder.h
+ * @author: Nick Barlow (nbarlow@mail.cern.ch, Kondo.Gnanvo@cern.ch)
+ * @date 21 June 2007 (SCT_RodEncoder turned into An AlgTool)
+ * 
+ * This class provides conversion from SCT RDO to ROD format ByteStream.
  */
  
-#ifndef SCT_RAWDATABYTESTREAM_SCT_RODENCODER_H
-#define SCT_RAWDATABYTESTREAM_SCT_RODENCODER_H
+#ifndef SCT_RAWDATABYTESTREAMCNV_SCT_RODENCODER_H
+#define SCT_RAWDATABYTESTREAMCNV_SCT_RODENCODER_H
 
-/// base classes
 #include "AthenaBaseComps/AthAlgTool.h"
 #include "SCT_RawDataByteStreamCnv/ISCT_RodEncoder.h"
 
-///InDet
-/**needed for typedef, cannot fwd declare */
 #include "InDetRawData/SCT_RDO_Container.h"
-#include "SCT_Cabling/ISCT_CablingTool.h"
 #include "SCT_ConditionsTools/ISCT_ByteStreamErrorsTool.h"
 
-///Gaudi
 #include "GaudiKernel/ToolHandle.h"
 
-///STL
 #include <set>
 
+class ISCT_CablingTool;
 class SCT_ID;
-
 class SCT_RDORawData;
 class Identifier;
 class IdentifierHash;
 
-/** Jan 09: make SCT_RodEncoder an AlgTool again, of which there
- * is one instance per job, rather than the lightweight class of 
+/** 
+ * @class SCT_RodEncoder
+ *
+ * @brief Athena Algorithm Tool that provides conversion from SCT RDO to ROD format Bytestream.
+ *
+ * This class inherits from AthAlgTool and ISCT_RodEncoder.
+ *
+ * Note from Jan 09: Make SCT_RodEncoder an AlgTool again, of which 
+ * there is one instance per job, rather than the lightweight class of 
  * which there was one instance per ROD.  This change is motivated
  * by the changes to write ByteStream errors back into the bytestream,
  * as we don't want to access the ByteStreamErrorsSvc 90 times per event
- * if we can avoid it.. */
- 
+ * if we can avoid it.. 
+ */
 class SCT_RodEncoder : public extends<AthAlgTool, ISCT_RodEncoder>
 { 
  public:
  
-  typedef SCT_RDORawData RDO;
-  typedef std::vector<const RDO*> vRDOs_t;
-  typedef SCT_RDO_Container SCTRawContainer;
-  
-  /** constructor  */
-
+  /** Constructor */
   SCT_RodEncoder(const std::string& type, const std::string& name, const IInterface* parent);
 
-  /** destructor  */
+  /** Destructor */
   virtual ~SCT_RodEncoder() = default;
 
-  /** AlgTool initialize */
-  virtual StatusCode initialize();
-
-  /** AlgTool finalize*/
-  virtual StatusCode finalize();
-
-  /// convert all collections of RDO's in the current  list to vector of 32bit words   
-  virtual void fillROD(std::vector<uint32_t>& v, const uint32_t& robid, vRDOs_t& rdoVec) const;
-
-  /// Encode rdo into the data: called by fillROD(..) 
-  void encodeData(std::vector<int>& vtbin, std::vector<uint16_t>& v16, const RDO *rdo, const int& gSize, const int& strip) const;
-  
-  /// pack 32 bit word:  called by  encodeData(..) 
-  void packFragments(std::vector<uint16_t>& v16, std::vector<uint32_t>& v32) const;
-
-  /// from 16 bits array to 32 bit array   
-  uint32_t set32bits(const unsigned short int* v16, const unsigned short int* pos, const unsigned short int& n) const;
-
-  /// Get the side info from the RDO 
-  int side(const RDO* rdo) const;
-  
-  /// Get the time bin info from the RDO
-  int tbin(const RDO* rdo) const;
-
-  /// Get the group size info from the RDO 
-  int groupSize(const RDO* rdo) const { return rdo->getGroupSize(); }
-  
-  /// Get the strip number info from the RDO  
-  int strip(const RDO* rdo) const;
- 
-  /// Get the offline Identifirer from the RDO  
-  Identifier offlineId(const RDO* rdo) const;
-
-  /// Get the online id from the RDO  
-  uint32_t onlineId(const RDO* rdo) const;
-
-  /// Get the ROD link info from the RDO 
-  int rodLink(const RDO* rdo) const;
-
-  /// Get the 16-bit word for a header for a hit 
-  uint16_t getHeaderUsingRDO(const RDO* rdo) const;
-  
-  /// Get the 16-bit word for a header for a link with a ByteStream error 
-  uint16_t getHeaderUsingHash(const IdentifierHash& linkHash, const int& errorWord) const;
-  
-  /// Get the 16-bit word for a trailer, with or without ByteStream errors 
-  uint16_t getTrailer(const int& errorword) const;
+  /** Initialize */
+  virtual StatusCode initialize() override;
+
+  /** Finalize */
+  virtual StatusCode finalize() override;
+
+  /**
+   * @brief Main Convert method
+   *
+   * Converts SCT RDO to a vector of 32 bit words. Starts by retrieving and collecting
+   * errors, then loops through RDO's and decode them to 16 bit words, and then
+   * finally it packs the 16 bit word into 32 bit words vector.
+   *
+   * @param vec32Data Vector of 32 bit words to be filled with encoded RDOs from the SCT.
+   * @param robID ID of the current readout buffer (ROB).
+   * @param vecRDOs Vector containing the RDOs to be coverted to vector of 32 bit words.
+   */
+  virtual void fillROD(std::vector<uint32_t>& vec32Data, const uint32_t& robID, 
+                       const std::vector<const SCT_RDORawData*>& vecRDOs) const override;
 
  private:
+  
+  /** Definitions of enum error words to be retrived from SCT_ByteStreamErrorSvc in fillROD(...) method */
   enum ErrorWords{TIMEOUT_ERR=(1<<11),
                   L1_ERR=(1<<10),
                   BCID_ERR=(1<<9),
@@ -118,17 +88,107 @@ class SCT_RodEncoder : public extends<AthAlgTool, ISCT_RodEncoder>
                   ABCD_ERR=0,
                   RAWDATA_ERR=(3<<13),
                   NULL_TRAILER_ERR=0}; 
-  void addHeadersWithErrors(const uint32_t& robid, const std::set<IdentifierHash>* errors, 
-                            const ErrorWords& errType, std::vector<uint16_t>& v16data) const;
-  void addTrailersWithErrors(const uint32_t& robid, const std::set<IdentifierHash>* errors, 
-                             const ErrorWords& errType, std::vector<uint16_t>& v16data) const;
-  void addSpecificErrors(const uint32_t& robid, const std::set<IdentifierHash>* errors, 
-                         const ErrorWords& errType, std::vector<uint16_t>& v16data) const;
-  ToolHandle<ISCT_ByteStreamErrorsTool> m_bsErrs{this, "SCT_ByteStreamErrorsTool", "SCT_ByteStreamErrorsTool", "Tool to retrieve SCT ByteStream Errors"};
-  ToolHandle<ISCT_CablingTool> m_cabling{this, "SCT_CablingTool", "SCT_CablingTool", "Tool to retrieve SCT Cabling"};
-  const SCT_ID* m_sct_id;
-  BooleanProperty m_condensed{this, "CondensedMode", false, "Condensed mode (true) or Expanded mode (false)"};
-  std::set<Identifier> m_swapModuleId; // Set by SCTRawContByteStreamTool
+
+  /**
+   * @brief Method to encode RDO data to vector of 16 bin words.
+   *
+   * Methods used by main convert methods fillROD(...).
+   *
+   * @param vecTimeBins Vector of time bins for RDOs.
+   * @param vec16Words Vector of 16 bit words to filled from encoded RDO data.
+   * @param rdo RDO raw data object to be encoded
+   * @param groupSize Group size info from the RDO
+   * @param strip Strip number info from the RDO
+   */
+  void encodeData(const std::vector<int>& vecTimeBins, std::vector<uint16_t>& vec16Words, 
+                  const SCT_RDORawData* rdo, const int& groupSize, const int& strip) const;
+  
+  /**
+   * @brief Method to pack vector of 16 bit words intto a vector of 32 bit words.
+   *
+   * Method us used by private method encodeData(...).
+   *
+   * @param vec16Words Vector containing 16 bit words.
+   * @param vec32Words Vector for 32 bit words to be packed
+   */
+  void packFragments(std::vector<uint16_t>& vec16Words, std::vector<uint32_t>& vec32Words) const;
+
+  /// from 16 bits array to 32 bit array   
+  /**
+   * @breif Method to set pairs of 16 bit words to a 32 bit word.
+   *
+   * Function used by the packFragments(...) method.
+   *
+   * @param arr16Words Pointer to array containing a pair of 16 bit words.
+   * @param position Pointer to an array that gives the 32 bit starting positions of the 16 bit words and corresponding to arr16Words.
+   * @param numWords Number of word to be set to a 32 bit word.
+   */
+  uint32_t set32Bits(const unsigned short int* arr16Words, 
+                     const unsigned short int* position, 
+                     const unsigned short int& numWords) const;
+
+  /** Get the side info from the RDO. */
+  int side(const SCT_RDORawData* rdo) const;
+  
+  /** Get the time bin info from the RDO. */
+  int getTimeBin(const SCT_RDORawData* rdo) const;
+  
+  /** Get the strip number info from the RDO. */
+  int getStrip(const SCT_RDORawData* rdo) const;
+ 
+  /** Get the offline Identifier from the RDO.  */
+  Identifier offlineID(const SCT_RDORawData* rdo) const;
+
+  /** Get the online Identifier from the RDO. */
+  uint32_t onlineID(const SCT_RDORawData* rdo) const;
+
+  /** Get the ROD link number info in the RDO header data. */
+  int getRODLink(const SCT_RDORawData* rdo) const;
+
+  /** Get the 16-bit word for a header for a hit. */
+  uint16_t getHeaderUsingRDO(const SCT_RDORawData* rdo) const;
+  
+  /** Get the 16-bit word for a header for a link with a ByteStream error. */
+  uint16_t getHeaderUsingHash(const IdentifierHash& linkHash, const int& errorWord) const;
+  
+  /** Get the 16-bit word for a trailer, with or without ByteStream errors. */
+  uint16_t getTrailer(const int& errorWord) const;
+
+  /** Add header with errors for ROB to the vector of 16 bit words. */
+  void addHeadersWithErrors(const uint32_t& robID, const std::set<IdentifierHash>* errors, 
+                            const ErrorWords& errType, std::vector<uint16_t>& vec16Data) const;
+
+  /** Add trailers with errors for ROB to the vector of 16 bit words. */
+  void addTrailersWithErrors(const uint32_t& robID, const std::set<IdentifierHash>* errors, 
+                             const ErrorWords& errType, std::vector<uint16_t>& vec16dDta) const;
+
+  /** Add specific errors for ROB to the vector of 16 bit words. */
+  void addSpecificErrors(const uint32_t& robID, const std::set<IdentifierHash>* errors, 
+                         const ErrorWords& errType, std::vector<uint16_t>& vec16Data) const;
+
+  /** Tool that keeps track of modules that give rise to errors in the bytestream. */
+  ToolHandle<ISCT_ByteStreamErrorsTool> m_bsErrTool{this, 
+                                                    "SCT_ByteStreamErrorsTool", 
+                                                    "SCT_ByteStreamErrorsTool", 
+                                                    "Tool to retrieve SCT ByteStream Errors"};
+  
+  /** Providing mappings of online and offline identifiers and also serial numbers. */
+  ToolHandle<ISCT_CablingTool> m_cabling{this, 
+                                         "SCT_CablingTool", 
+                                         "SCT_CablingTool", 
+                                         "Tool to retrieve SCT Cabling"};
+  /** Identifier helper class for the SCT subdetector that creates compact Identifier objects and 
+      IdentifierHash or hash IDs. Also allows decoding of these IDs. */
+  const SCT_ID* m_sctID;
+
+  /** Boolean used to determine if fillROD(...) should use Condensed or Expanded mode when decoding. */
+  BooleanProperty m_condensed{this, 
+                              "CondensedMode", 
+                              false, 
+                              "Condensed mode (true) or Expanded mode (false)"};
+
+  /** Swap Module identifier, set by SCTRawContByteStreamTool. */
+  std::set<Identifier> m_swapModuleID;
 };
 
-#endif // SCT_RAWDATABYTESTREAM_SCT_RODENCODER_H
+#endif // SCT_RAWDATABYTESTREAMCNV_SCT_RODENCODER_H