diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.cxx b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.cxx
index af4232c7bd7c0e78f558e74c307ca266866d8b8d..fed1efd85b9dc61fc3f12af7f1815cf5ae0531e5 100644
--- a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.cxx
+++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTAlignCondAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -154,7 +154,6 @@ StatusCode TRTAlignCondAlg::execute()
     return StatusCode::FAILURE;
   }
 
-
   const InDetDD::TRT_DetElementCollection* alignedColl{m_detManager->getDetectorElementCollection()};
   if (alignedColl==nullptr) {
     ATH_MSG_FATAL("Null pointer is returned by getDetectorElementCollection()");
@@ -165,89 +164,56 @@ StatusCode TRTAlignCondAlg::execute()
   std::unique_ptr<InDetDD::TRT_DetElementContainer> writeCdoDetElCont{std::make_unique<InDetDD::TRT_DetElementContainer>()};
   
   // ____________ Update writeCdo using readCdo ____________                                                                                   
-  std::map<const InDetDD::TRT_BaseElement*, const InDetDD::TRT_BaseElement*> oldToNewMap;
-  std::map<const InDetDD::TRT_EndcapElement*, const InDetDD::TRT_EndcapElement*> oldToNewECMap;
-  std::map<const InDetDD::TRT_BarrelElement*, const InDetDD::TRT_BarrelElement*> oldToNewBAMap;
-
+  std::map<const InDetDD::TRT_EndcapElement*, InDetDD::TRT_EndcapElement*> oldToNewECMap;
+  std::map<const InDetDD::TRT_BarrelElement*, InDetDD::TRT_BarrelElement*> oldToNewBAMap;
 
-  oldToNewMap[nullptr] = nullptr;
   oldToNewECMap[nullptr] = nullptr;
   oldToNewBAMap[nullptr] = nullptr;
 
-  std::unique_ptr<InDetDD::TRT_DetElementCollection> newDetElColl{std::make_unique<InDetDD::TRT_DetElementCollection>()};
-
-  newDetElColl->resize(alignedColl->size(), nullptr);
-
-  //Will create a new aligned detector element collection
-  InDetDD::TRT_DetElementCollection::iterator newEl{newDetElColl->begin()};
-  for (const InDetDD::TRT_BaseElement* oldEl: *alignedColl) {
-
+  //Create new aligned detector elements
+  for (const InDetDD::TRT_BaseElement* oldEl : *alignedColl) {
     InDetDD::TRT_BaseElement::Type type = oldEl->type();
 
-    if(type == InDetDD::TRT_BaseElement::ENDCAP)
-      {
-	const InDetDD::TRT_EndcapElement* oldEl_Endcap = static_cast<const InDetDD::TRT_EndcapElement*>(oldEl);
-	//New encap element with new alignment created based on old element
-        *newEl = new InDetDD::TRT_EndcapElement(*oldEl_Endcap,writeCdo.get());
-       	oldToNewMap[oldEl]= *newEl;
-	oldToNewECMap[oldEl_Endcap]= dynamic_cast<const InDetDD::TRT_EndcapElement*>(*newEl);
-
-      }else if(type == InDetDD::TRT_BaseElement::BARREL){
-        const InDetDD::TRT_BarrelElement* oldEl_Barrel = static_cast<const InDetDD::TRT_BarrelElement*>(oldEl);
-        //New barrel element with new alignment created based on old element
-        *newEl = new InDetDD::TRT_BarrelElement(*oldEl_Barrel,writeCdo.get());
-        oldToNewMap[oldEl]= *newEl;
-        oldToNewBAMap[oldEl_Barrel]= dynamic_cast<const InDetDD::TRT_BarrelElement*>(*newEl);
-
-    }else{
+    if(type == InDetDD::TRT_BaseElement::ENDCAP) {
+      const InDetDD::TRT_EndcapElement* oldEl_Endcap = static_cast<const InDetDD::TRT_EndcapElement*>(oldEl);
+      //New encap element with new alignment created based on old element
+      InDetDD::TRT_EndcapElement* newEl = new InDetDD::TRT_EndcapElement(*oldEl_Endcap,writeCdo.get());
+      oldToNewECMap[oldEl_Endcap] = newEl;
+      writeCdoDetElCont->addEndcapElement(newEl);
+    } else if (type == InDetDD::TRT_BaseElement::BARREL) {
+      const InDetDD::TRT_BarrelElement* oldEl_Barrel = static_cast<const InDetDD::TRT_BarrelElement*>(oldEl);
+      //New barrel element with new alignment created based on old element
+      InDetDD::TRT_BarrelElement* newEl = new InDetDD::TRT_BarrelElement(*oldEl_Barrel,writeCdo.get());
+      oldToNewBAMap[oldEl_Barrel] = newEl;
+      writeCdoDetElCont->addBarrelElement(newEl);
+    } else {
       ATH_MSG_FATAL("Unknown TRT detector element found");
       return StatusCode::FAILURE;
     }
-    newEl++;
   }
 
   //Set detector elements links
-  InDetDD::TRT_DetElementCollection::const_iterator oldIt{alignedColl->begin()};
-  for (InDetDD::TRT_BaseElement* newEl: *newDetElColl) {
-    if (oldToNewMap[(*oldIt)]!=newEl) {
-      ATH_MSG_ERROR("Old and new elements are not synchronized!");
-    }
-    InDetDD::TRT_BaseElement::Type type = newEl->type();
-    if(type == InDetDD::TRT_BaseElement::ENDCAP){
-      InDetDD::TRT_EndcapElement* newEl_Endcap = static_cast<InDetDD::TRT_EndcapElement*>(newEl);
-      InDetDD::TRT_EndcapElement* oldEl_Endcap = static_cast<InDetDD::TRT_EndcapElement*>(*oldIt);
-      newEl_Endcap->setNextInZ(oldToNewECMap[oldEl_Endcap->nextInZ()]);
-      newEl_Endcap->setPreviousInZ(oldToNewECMap[oldEl_Endcap->previousInZ()]);
-      newEl = newEl_Endcap;
-    }else if(type == InDetDD::TRT_BaseElement::BARREL){
-      InDetDD::TRT_BarrelElement* newEl_Barrel = static_cast<InDetDD::TRT_BarrelElement*>(newEl);
-      InDetDD::TRT_BarrelElement* oldEl_Barrel = static_cast<InDetDD::TRT_BarrelElement*>(*oldIt);
-      newEl_Barrel->setNextInR(oldToNewBAMap[oldEl_Barrel->nextInR()]);
-      newEl_Barrel->setPreviousInR(oldToNewBAMap[oldEl_Barrel->previousInR()]);
-      newEl_Barrel->setNextInPhi(oldToNewBAMap[oldEl_Barrel->nextInPhi()]);
-      newEl_Barrel->setPreviousInPhi(oldToNewBAMap[oldEl_Barrel->previousInPhi()]);
-      newEl = newEl_Barrel;
-    }
-    oldIt++;
+  for (auto pairOfEl : oldToNewECMap) {
+    if (!pairOfEl.first) continue; // skip nullptr
+    pairOfEl.second->setNextInZ(oldToNewECMap[pairOfEl.first->nextInZ()]);
+    pairOfEl.second->setPreviousInZ(oldToNewECMap[pairOfEl.first->previousInZ()]);
+  }
+  for (auto pairOfEl : oldToNewBAMap) {
+    if (!pairOfEl.first) continue; // skip nullptr
+    pairOfEl.second->setNextInR(oldToNewBAMap[pairOfEl.first->nextInR()]);
+    pairOfEl.second->setPreviousInR(oldToNewBAMap[pairOfEl.first->previousInR()]);
+    pairOfEl.second->setNextInPhi(oldToNewBAMap[pairOfEl.first->nextInPhi()]);
+    pairOfEl.second->setPreviousInPhi(oldToNewBAMap[pairOfEl.first->previousInPhi()]);
   }
 
-  // Update all detector elements caches and add aligned det elements to the corresponding array based on their type
-  for (InDetDD::TRT_BaseElement* newEl: *newDetElColl) {
+  // Update all detector elements caches
+  for (InDetDD::TRT_BaseElement* newEl : *(writeCdoDetElCont->getElements())) {
     newEl->updateAllCaches();
-    InDetDD::TRT_BaseElement::Type type = newEl->type();
-    if(type == InDetDD::TRT_BaseElement::ENDCAP){
-      InDetDD::TRT_EndcapElement* newEl_Endcap = dynamic_cast<InDetDD::TRT_EndcapElement*>(newEl);
-      writeCdoDetElCont->addEndcapElement(newEl_Endcap);
-    }else if(type == InDetDD::TRT_BaseElement::BARREL){
-      InDetDD::TRT_BarrelElement* newEl_Barrel = dynamic_cast<InDetDD::TRT_BarrelElement*>(newEl);
-      writeCdoDetElCont->addBarrelElement(newEl_Barrel);
-    }    
   }
 
-  // Record WriteCondHandle (size is meaningless here?)
-  const std::size_t size{newDetElColl->size()};
+  // Record WriteCondHandle
+  const std::size_t writeHandleDetElContSize{writeCdoDetElCont->getElements()->size()};
 
-  writeCdoDetElCont->setDetElementCollection(newDetElColl.release());
   writeCdoDetElCont->setNumerology(m_detManager->getNumerology());
 
   // Record the resulting CDO
@@ -265,7 +231,7 @@ StatusCode TRTAlignCondAlg::execute()
                   << " into Conditions Store");
     return StatusCode::FAILURE;
   }
-  ATH_MSG_INFO("recorded new CDO " << writeHandleDetElCont.key() << " with range " << rangeW << " with size of " << size << " into Conditions Store");
+  ATH_MSG_INFO("recorded new CDO " << writeHandleDetElCont.key() << " with range " << rangeW << " with size of " << writeHandleDetElContSize << " into Conditions Store");
 
   return StatusCode::SUCCESS;
 }
diff --git a/InnerDetector/InDetDetDescr/TRT_ReadoutGeometry/TRT_ReadoutGeometry/TRT_DetElementContainer.h b/InnerDetector/InDetDetDescr/TRT_ReadoutGeometry/TRT_ReadoutGeometry/TRT_DetElementContainer.h
index bf4a2dbe8c1802f47c53ea7e73dc80ccaddaa627..e448e494a61284239a6497434ed363e7a3b0501a 100755
--- a/InnerDetector/InDetDetDescr/TRT_ReadoutGeometry/TRT_ReadoutGeometry/TRT_DetElementContainer.h
+++ b/InnerDetector/InDetDetDescr/TRT_ReadoutGeometry/TRT_ReadoutGeometry/TRT_DetElementContainer.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef INDETREADOUTGEOMETRY_TRT_DETELEMENTCONTAINER_H
@@ -25,8 +25,10 @@ class TRT_DetElementContainer{
 
   TRT_DetElementContainer();
   ~TRT_DetElementContainer();
-
-  void setDetElementCollection(TRT_DetElementCollection* mytrtcoll); 
+  // disable implicit copy constructor
+  TRT_DetElementContainer(const TRT_DetElementContainer& other) = delete;
+  // disable implicit assignment operator
+  void operator = (const TRT_DetElementContainer& other) = delete;
 
   void setNumerology(const TRT_Numerology* mynum);
 
@@ -47,9 +49,11 @@ class TRT_DetElementContainer{
 					    unsigned int phiIndex,
 					    unsigned int strawLayerIndex) const;
 
+  void clear();
+
  private:
 
-  TRT_DetElementCollection* m_trtcoll;
+  TRT_DetElementCollection m_trtcoll;
   const TRT_Numerology  *m_trtnum;
 
   enum {NMODMAX=3};
diff --git a/InnerDetector/InDetDetDescr/TRT_ReadoutGeometry/src/TRT_DetElementContainer.cxx b/InnerDetector/InDetDetDescr/TRT_ReadoutGeometry/src/TRT_DetElementContainer.cxx
index 4de70dbf9e7473cef3cd8ef3416b51bce552f8f9..3822c0ff6f7acf2b66f268426ed23c75e518ac35 100644
--- a/InnerDetector/InDetDetDescr/TRT_ReadoutGeometry/src/TRT_DetElementContainer.cxx
+++ b/InnerDetector/InDetDetDescr/TRT_ReadoutGeometry/src/TRT_DetElementContainer.cxx
@@ -1,6 +1,6 @@
 
 /*                                                                                                                                          
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TRT_ReadoutGeometry/TRT_DetElementContainer.h"
@@ -10,38 +10,15 @@
 namespace InDetDD{
 
   TRT_DetElementContainer::TRT_DetElementContainer():
-    m_trtcoll(nullptr),
+    m_trtcoll(),
     m_trtnum(nullptr)
   {
-
-    for (unsigned int ec=0;ec<2;ec++) {
-      for (unsigned int mod=0;mod<NMODMAX;mod++) {
-	for (unsigned int phi=0; phi<NPHIMAX;phi++) {
-	  for (unsigned int sLay=0;sLay<NSTRAWLAYMAXBR;sLay++) {
-	    m_baArray[ec][mod][phi][sLay]=nullptr;
-	  }
-	}
-      }
-    }
-    for (unsigned int ec=0;ec<2;ec++) {
-      for (unsigned int whe=0;whe<NWHEELMAX;whe++) {
-	for (unsigned int sLay=0;sLay<NSTRAWLAYMAXEC;sLay++) {
-	  for(unsigned int phi=0;phi<NPHIMAX;phi++) {
-	    m_ecArray[ec][whe][sLay][phi]=nullptr;
-	  }
-	}
-      }
-    }
+    clear();
   }
 
-
   TRT_DetElementContainer::~TRT_DetElementContainer()
   {
-  }
-
-
-  void TRT_DetElementContainer::setDetElementCollection(TRT_DetElementCollection* mytrtcoll) {
-    m_trtcoll=mytrtcoll;
+    clear();
   }
 
   void TRT_DetElementContainer::setNumerology(const TRT_Numerology* mynum) {
@@ -50,7 +27,7 @@ namespace InDetDD{
 
   const TRT_DetElementCollection* TRT_DetElementContainer::getElements() const
   { 
-    return m_trtcoll;
+    return &m_trtcoll;
   }
 
   const TRT_Numerology* TRT_DetElementContainer::getTRTNumerology() const
@@ -81,24 +58,70 @@ namespace InDetDD{
 
   void TRT_DetElementContainer::addBarrelElement(TRT_BarrelElement *barrel) 
   {
-
-    m_baArray
+    // check if the element has already been added
+    if (std::find(m_trtcoll.begin(), m_trtcoll.end(), barrel) != m_trtcoll.end()) return;
+    // check if something was stored at the given indices 
+    TRT_BarrelElement* arrayElement = m_baArray
       [barrel->getCode().isPosZ()]
       [barrel->getCode().getModuleIndex()]
       [barrel->getCode().getPhiIndex()]
-      [barrel->getCode().getStrawLayerIndex()]
-      =barrel;
+      [barrel->getCode().getStrawLayerIndex()];
+    if (arrayElement != nullptr) {
+      m_trtcoll.erase(std::remove(m_trtcoll.begin(), m_trtcoll.end(), arrayElement));
+      delete arrayElement;
+    }
+    m_baArray[barrel->getCode().isPosZ()]
+      [barrel->getCode().getModuleIndex()]
+      [barrel->getCode().getPhiIndex()]
+      [barrel->getCode().getStrawLayerIndex()] = barrel;
+    m_trtcoll.push_back(barrel);
   }
 
   void TRT_DetElementContainer::addEndcapElement(TRT_EndcapElement *endcap)
   {
-
-    m_ecArray
+    // check if the element has already been added
+    if (std::find(m_trtcoll.begin(), m_trtcoll.end(), endcap) != m_trtcoll.end()) return;
+    // check if something was stored at the given indices 
+    TRT_EndcapElement* arrayElement = m_ecArray
       [endcap->getCode().isPosZ()]
       [endcap->getCode().getWheelIndex()]
       [endcap->getCode().getStrawLayerIndex()]
-      [endcap->getCode().getPhiIndex()]
-      =endcap;
+      [endcap->getCode().getPhiIndex()];
+    if (arrayElement != nullptr) {
+      m_trtcoll.erase(std::remove(m_trtcoll.begin(), m_trtcoll.end(), arrayElement));
+      delete arrayElement;
+    }
+    m_ecArray[endcap->getCode().isPosZ()]
+      [endcap->getCode().getWheelIndex()]
+      [endcap->getCode().getStrawLayerIndex()]
+      [endcap->getCode().getPhiIndex()] = endcap;
+    m_trtcoll.push_back(endcap);
+  }
+
+  void TRT_DetElementContainer::clear()
+  {
+    for (auto p : m_trtcoll) {
+      delete p;
+    }
+    m_trtcoll.clear();
+    for (unsigned int ec=0;ec<2;ec++) {
+      for (unsigned int mod=0;mod<NMODMAX;mod++) {
+        for (unsigned int phi=0; phi<NPHIMAX;phi++) {
+          for (unsigned int sLay=0;sLay<NSTRAWLAYMAXBR;sLay++) {
+            m_baArray[ec][mod][phi][sLay] = nullptr;
+          }
+        }
+      }
+    }
+    for (unsigned int ec=0;ec<2;ec++) {
+      for (unsigned int whe=0;whe<NWHEELMAX;whe++) {
+        for (unsigned int sLay=0;sLay<NSTRAWLAYMAXEC;sLay++) {
+          for(unsigned int phi=0;phi<NPHIMAX;phi++) {
+            m_ecArray[ec][whe][sLay][phi] = nullptr;
+          }
+        }
+      }
+    }
   }
      
 }
diff --git a/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadData_xk.h b/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadData_xk.h
index 640da6ac9f227127a1bd163ed75d37b5e77a02f3..d799ffaccbb0af9a931e8fc5c4a317aeeaeb1bae 100644
--- a/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadData_xk.h
+++ b/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadTool_xk/TRT_DetElementsRoadData_xk.h
@@ -16,18 +16,18 @@ namespace InDet{
    TRT_DetElementsRoadData_xk()=default;
    ~TRT_DetElementsRoadData_xk()=default;
 
-   inline void setTRTLayerVectors(TRT_DetElementsLayerVectors_xk* layers){m_TRTLayerVectors=layers;}
+   inline void setTRTLayerVectors(const TRT_DetElementsLayerVectors_xk& layers){m_TRTLayerVectors=layers;}
    inline void setBounds(Trk::CylinderBounds cbounds, double rmintrt){m_bounds=cbounds;m_rminTRT=rmintrt;}
 
-   inline const TRT_DetElementsLayerVectors_xk* getLayers() const {return m_TRTLayerVectors;}
+   inline const TRT_DetElementsLayerVectors_xk* getLayers() const {return &m_TRTLayerVectors;}
    inline const Trk::CylinderBounds getBounds() const {return m_bounds;}
    inline double getTRTMinR() const {return m_rminTRT;}
 
    private: 
 
-   const TRT_DetElementsLayerVectors_xk*      m_TRTLayerVectors;
-   double                                     m_rminTRT{};
-   Trk::CylinderBounds                           m_bounds;
+   TRT_DetElementsLayerVectors_xk m_TRTLayerVectors;
+   double                         m_rminTRT{};
+   Trk::CylinderBounds            m_bounds;
  };
 
 }
diff --git a/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/src/TRT_DetElementsRoadCondAlg_xk.cxx b/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/src/TRT_DetElementsRoadCondAlg_xk.cxx
index d582cccbd767974a78068f0f7a817dae37ee3d72..3d06d209cc71d0c25cc125d615dd1caa9a0074da 100644
--- a/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/src/TRT_DetElementsRoadCondAlg_xk.cxx
+++ b/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/src/TRT_DetElementsRoadCondAlg_xk.cxx
@@ -75,7 +75,7 @@ StatusCode InDet::TRT_DetElementsRoadCondAlg_xk::execute(const EventContext& ctx
     ATH_MSG_FATAL("Pointer to TRT_Numerology not found in condition store" << m_trtDetEleContKey.fullKey());
   }
 
-  InDet::TRT_DetElementsLayerVectors_xk* layerVectors = new InDet::TRT_DetElementsLayerVectors_xk(3);
+  InDet::TRT_DetElementsLayerVectors_xk layerVectors(3);
 
   if (not trtDetEleHandle.range(rangeTrt)) {
     ATH_MSG_FATAL("Failed to retrieve validity range for " << trtDetEleHandle.key());
@@ -148,7 +148,7 @@ StatusCode InDet::TRT_DetElementsRoadCondAlg_xk::execute(const EventContext& ctx
       double z  =(zmax+zmin)*.5;
       double dz =(zmax-zmin)*.5;
       layer.set(r,dr,z,dz,dfm,Wf,Wz);
-      (layerVectors->at(N)).push_back(std::move(layer));
+      (layerVectors.at(N)).push_back(std::move(layer));
 
     }
   }
@@ -213,7 +213,7 @@ StatusCode InDet::TRT_DetElementsRoadCondAlg_xk::execute(const EventContext& ctx
 	  double z  =(zmax+zmin)*.5;
 	  double dz =(zmax-zmin)*.5;
 	  layer.set(r,dr,z,dz,dfm,Wf,Wz);
-	  (layerVectors->at(N)).push_back(std::move(layer));
+	  (layerVectors.at(N)).push_back(std::move(layer));
 	}
       }
     }