From 191b642000d479b92fe9ed4a057cb759046d5276 Mon Sep 17 00:00:00 2001
From: Gerhard Raven <gerhard.raven@nikhef.nl>
Date: Thu, 12 Apr 2018 07:48:41 +0000
Subject: [PATCH] Modernize Registry usage in (Ts)DataSvc

---
 GaudiAlg/GaudiAlg/ScalarTransformer.h         |   4 +-
 GaudiAlg/GaudiAlg/SplittingTransformer.h      |   2 +-
 GaudiCommonSvc/src/DataSvc/RecordDataSvc.cpp  |  15 +-
 .../PersistencySvc/DataSvcFileEntriesTool.cpp |   8 +-
 .../src/PersistencySvc/OutputStream.h         |   6 +-
 .../src/PersistencySvc/OutputStreamAgent.h    |   2 +-
 GaudiHive/src/AlgsExecutionStates.h           |   6 +-
 GaudiHive/src/AvalancheSchedulerSvc.cpp       |  24 +-
 GaudiHive/src/PrecedenceRulesGraph.cpp        |  22 +-
 GaudiHive/src/PrecedenceRulesGraph.h          |  46 ++--
 GaudiKernel/GaudiKernel/AlgTool.h             |  32 +--
 GaudiKernel/GaudiKernel/Algorithm.h           |  70 ++---
 GaudiKernel/GaudiKernel/Converter.h           |   6 +-
 GaudiKernel/GaudiKernel/DataObject.h          |   2 +-
 GaudiKernel/GaudiKernel/DataSvc.h             |  18 +-
 GaudiKernel/GaudiKernel/GenericAddress.h      |   2 +-
 GaudiKernel/GaudiKernel/IDataManagerSvc.h     |   2 +-
 GaudiKernel/GaudiKernel/IDataProviderSvc.h    |   2 +-
 GaudiKernel/GaudiKernel/IDataStoreAgent.h     |   2 +-
 GaudiKernel/GaudiKernel/IHistogramSvc.h       |   1 +
 GaudiKernel/GaudiKernel/IOpaqueAddress.h      |   2 +-
 GaudiKernel/GaudiKernel/IRegistry.h           |  54 +---
 GaudiKernel/GaudiKernel/LinkManager.h         |  15 +-
 GaudiKernel/GaudiKernel/RegistryEntry.h       |  93 +++----
 GaudiKernel/GaudiKernel/SmartDataObjectPtr.h  |   2 +-
 GaudiKernel/GaudiKernel/TsDataSvc.h           |  15 +-
 GaudiKernel/src/Lib/DataSvc.cpp               | 253 ++++++++----------
 GaudiKernel/src/Lib/LinkManager.cpp           |  65 ++---
 GaudiKernel/src/Lib/RegistryEntry.cpp         | 195 +++++++-------
 GaudiKernel/src/Lib/TsDataSvc.cpp             | 219 +++++++--------
 GaudiPython/python/GaudiPython/Bindings.py    |   2 +-
 GaudiUtils/GaudiUtils/IFileCatalog.h          |   4 +-
 GaudiUtils/src/component/MultiFileCatalog.h   |   4 +-
 GaudiUtils/src/component/XMLFileCatalog.cpp   |  38 +--
 GaudiUtils/src/component/XMLFileCatalog.h     |  12 +-
 RootCnv/RootCnv/RootDataConnection.h          |  32 +--
 36 files changed, 555 insertions(+), 722 deletions(-)

diff --git a/GaudiAlg/GaudiAlg/ScalarTransformer.h b/GaudiAlg/GaudiAlg/ScalarTransformer.h
index 6ea866178..ce74d935d 100644
--- a/GaudiAlg/GaudiAlg/ScalarTransformer.h
+++ b/GaudiAlg/GaudiAlg/ScalarTransformer.h
@@ -25,7 +25,7 @@ namespace Gaudi
       Out operator()( const In&... in ) const override final
       {
         const auto inrange = details::zip::const_range( in... );
-        Out out;
+        Out        out;
         out.reserve( inrange.size() );
         auto& scalar = scalarOp();
         for ( const auto&& tuple : inrange ) {
@@ -55,7 +55,7 @@ namespace Gaudi
       /// The main operator
       std::tuple<Out...> operator()( const In&... in ) const final
       {
-        const auto inrange = details::zip::const_range( in... );
+        const auto         inrange = details::zip::const_range( in... );
         std::tuple<Out...> out;
         Gaudi::apply(
             [sz = inrange.size()]( auto&&... o ) {
diff --git a/GaudiAlg/GaudiAlg/SplittingTransformer.h b/GaudiAlg/GaudiAlg/SplittingTransformer.h
index cf95f65db..dd02624ed 100644
--- a/GaudiAlg/GaudiAlg/SplittingTransformer.h
+++ b/GaudiAlg/GaudiAlg/SplittingTransformer.h
@@ -46,7 +46,7 @@ namespace Gaudi
 
       // accessor to output Locations
       const std::string& outputLocation( unsigned int n ) const { return m_outputLocations[n]; }
-      unsigned int outputLocationSize() const { return m_outputLocations.size(); }
+      unsigned int                                    outputLocationSize() const { return m_outputLocations.size(); }
 
       // derived classes can NOT implement execute
       StatusCode execute() override final
diff --git a/GaudiCommonSvc/src/DataSvc/RecordDataSvc.cpp b/GaudiCommonSvc/src/DataSvc/RecordDataSvc.cpp
index 513cfea46..ebef36088 100644
--- a/GaudiCommonSvc/src/DataSvc/RecordDataSvc.cpp
+++ b/GaudiCommonSvc/src/DataSvc/RecordDataSvc.cpp
@@ -93,7 +93,7 @@ void RecordDataSvc::handle( const Incident& incident )
 {
   if ( incident.type() == "FILE_OPEN_READ" ) {
     typedef ContextIncident<IOpaqueAddress*> Ctxt;
-    auto inc = dynamic_cast<const Ctxt*>( &incident );
+    auto                                     inc = dynamic_cast<const Ctxt*>( &incident );
     if ( !inc ) {
       always() << "Received invalid incident of type:" << incident.type() << endmsg;
     } else {
@@ -116,9 +116,9 @@ void RecordDataSvc::loadRecords( IRegistry* pObj )
     error() << "Failed to load records object: " << pObj->identifier() << endmsg;
   } else {
     vector<IRegistry*> leaves;
-    DataObject* p     = nullptr;
-    const string& id0 = pObj->identifier();
-    StatusCode sc     = retrieveObject( id0, p );
+    DataObject*        p   = nullptr;
+    const string&      id0 = pObj->identifier();
+    StatusCode         sc  = retrieveObject( id0, p );
     if ( sc.isSuccess() ) {
       debug() << "Loaded records object: " << id0 << endmsg;
       sc = objectLeaves( pObj, leaves );
@@ -135,7 +135,7 @@ void RecordDataSvc::registerRecord( const string& data, IOpaqueAddress* pAddr )
   if ( !data.empty() && pAddr ) {
     string fid = data;
     debug() << "Request to load record for file " << fid << endmsg;
-    StatusCode sc = registerAddress( m_root, fid, pAddr );
+    StatusCode sc = registerAddress( m_root.get(), fid, pAddr );
     if ( !sc.isSuccess() ) {
       warning() << "Failed to register record for:" << fid << endmsg;
       pAddr->release();
@@ -151,7 +151,4 @@ void RecordDataSvc::registerRecord( const string& data, IOpaqueAddress* pAddr )
 }
 
 /// Standard Constructor
-RecordDataSvc::RecordDataSvc( const string& name, ISvcLocator* svc ) : base_class( name, svc )
-{
-  m_rootName = "/Records";
-}
+RecordDataSvc::RecordDataSvc( const string& name, ISvcLocator* svc ) : extends( name, svc ) { m_rootName = "/Records"; }
diff --git a/GaudiCommonSvc/src/PersistencySvc/DataSvcFileEntriesTool.cpp b/GaudiCommonSvc/src/PersistencySvc/DataSvcFileEntriesTool.cpp
index 092d5ed8d..55d7d1dbd 100644
--- a/GaudiCommonSvc/src/PersistencySvc/DataSvcFileEntriesTool.cpp
+++ b/GaudiCommonSvc/src/PersistencySvc/DataSvcFileEntriesTool.cpp
@@ -7,7 +7,7 @@
 class IIncidentSvc;
 struct IDataManagerSvc;
 class IDataProviderSvc;
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 /**
  * Tool to scan a transient store branch that collects all the objects that belong
  * to the same source (file).
@@ -50,7 +50,7 @@ public:
 private:
   Gaudi::Property<std::string> m_dataSvcName{this, "DataService", "EventDataSvc", "Name of the data service to use"};
   Gaudi::Property<std::string> m_rootNode{this, "Root", "", "Path to the element from which to start the scan"};
-  Gaudi::Property<bool> m_scanOnBeginEvent{
+  Gaudi::Property<bool>        m_scanOnBeginEvent{
       this, "ScanOnBeginEvent", false,
       "If the scan has to be started during the BeginEvent incident (true) or on demand (false, default)"};
   Gaudi::Property<bool> m_ignoreOriginChange{
@@ -167,7 +167,7 @@ const IDataStoreLeaves::LeavesList& DataSvcFileEntriesTool::leaves() const
 IRegistry* DataSvcFileEntriesTool::i_getRootNode()
 {
   DataObject* obj = nullptr;
-  StatusCode sc   = m_dataSvc->retrieveObject( m_rootNode.value(), obj );
+  StatusCode  sc  = m_dataSvc->retrieveObject( m_rootNode.value(), obj );
   if ( sc.isFailure() ) {
     throw GaudiException( "Cannot get " + m_rootNode + " from " + m_dataSvcName, name(), StatusCode::FAILURE );
   }
@@ -194,7 +194,7 @@ void DataSvcFileEntriesTool::i_collectLeaves( IRegistry* reg )
                             name(), StatusCode::FAILURE );
 
     std::vector<IRegistry*> lfs; // leaves of the current object
-    StatusCode sc = m_dataMgrSvc->objectLeaves( reg, lfs );
+    StatusCode              sc = m_dataMgrSvc->objectLeaves( reg, lfs );
     if ( sc.isSuccess() ) {
       for ( const auto& i : lfs ) {
         // Continue if the leaf has the same database as the parent
diff --git a/GaudiCommonSvc/src/PersistencySvc/OutputStream.h b/GaudiCommonSvc/src/PersistencySvc/OutputStream.h
index 2b741508e..9a4b1eeb0 100644
--- a/GaudiCommonSvc/src/PersistencySvc/OutputStream.h
+++ b/GaudiCommonSvc/src/PersistencySvc/OutputStream.h
@@ -15,7 +15,7 @@
 
 // forward declarations
 class IIncidentSvc;
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 class IConversionSvc;
 struct IDataManagerSvc;
 class OutputStreamAgent;
@@ -30,8 +30,8 @@ class OutputStream : public Algorithm
 {
 public:
   typedef std::vector<DataStoreItem*> Items;
-  typedef std::vector<std::string> ItemNames;
-  typedef std::map<Algorithm*, Items> AlgDependentItems;
+  typedef std::vector<std::string>    ItemNames;
+  typedef std::map<Algorithm*, Items>      AlgDependentItems;
   typedef std::map<std::string, ItemNames> AlgDependentItemNames;
 
 protected:
diff --git a/GaudiCommonSvc/src/PersistencySvc/OutputStreamAgent.h b/GaudiCommonSvc/src/PersistencySvc/OutputStreamAgent.h
index b0cd9fab2..49ebae0ae 100644
--- a/GaudiCommonSvc/src/PersistencySvc/OutputStreamAgent.h
+++ b/GaudiCommonSvc/src/PersistencySvc/OutputStreamAgent.h
@@ -17,7 +17,7 @@
 // Framework includes
 #include "GaudiKernel/IDataStoreAgent.h"
 // Foreward declarations
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 class OutputStream;
 
 /** @name The OutputStreamAgent class.
diff --git a/GaudiHive/src/AlgsExecutionStates.h b/GaudiHive/src/AlgsExecutionStates.h
index 522728b27..0331818b7 100644
--- a/GaudiHive/src/AlgsExecutionStates.h
+++ b/GaudiHive/src/AlgsExecutionStates.h
@@ -66,7 +66,7 @@ public:
   }
 
 private:
-  std::vector<State> m_states;
+  std::vector<State>   m_states;
   SmartIF<IMessageSvc> m_MS;
 
   MsgStream log() { return {m_MS, "AlgsExecutionStates"}; }
@@ -100,8 +100,8 @@ public:
     uint operator*() { return std::distance( m_v->begin(), m_pos ); }
 
   private:
-    State m_s;
-    const std::vector<State>* m_v;
+    State                              m_s;
+    const std::vector<State>*          m_v;
     std::vector<State>::const_iterator m_pos;
   };
 
diff --git a/GaudiHive/src/AvalancheSchedulerSvc.cpp b/GaudiHive/src/AvalancheSchedulerSvc.cpp
index 102a99b4e..59df33f2b 100644
--- a/GaudiHive/src/AvalancheSchedulerSvc.cpp
+++ b/GaudiHive/src/AvalancheSchedulerSvc.cpp
@@ -132,8 +132,8 @@ StatusCode AvalancheSchedulerSvc::initialize()
   Gaudi::Concurrency::ConcurrencyFlags::setNumConcEvents( m_maxEventsInFlight );
 
   // Get the list of algorithms
-  const std::list<IAlgorithm*>& algos = m_algResourcePool->getFlatAlgList();
-  const unsigned int algsNumber       = algos.size();
+  const std::list<IAlgorithm*>& algos      = m_algResourcePool->getFlatAlgList();
+  const unsigned int            algsNumber = algos.size();
   info() << "Found " << algsNumber << " algorithms" << endmsg;
 
   /* Dependencies
@@ -292,7 +292,7 @@ StatusCode AvalancheSchedulerSvc::initialize()
   m_algname_vect.resize( algsNumber );
   for ( IAlgorithm* algo : algos ) {
     const std::string& name    = algo->name();
-    auto index                 = precSvc->getRules()->getAlgorithmNode( name )->getAlgoIndex();
+    auto               index   = precSvc->getRules()->getAlgorithmNode( name )->getAlgoIndex();
     m_algname_index_map[name]  = index;
     m_algname_vect.at( index ) = name;
   }
@@ -371,7 +371,7 @@ void AvalancheSchedulerSvc::activate()
   }
 
   // Wait for actions pushed into the queue by finishing tasks.
-  action thisAction;
+  action     thisAction;
   StatusCode sc( StatusCode::SUCCESS );
 
   m_isActive = ACTIVE;
@@ -467,7 +467,7 @@ StatusCode AvalancheSchedulerSvc::pushNewEvent( EventContext* eventContext )
   auto action = [this, eventContext]() -> StatusCode {
     // Event processing slot forced to be the same as the wb slot
     const unsigned int thisSlotNum = eventContext->slot();
-    EventSlot& thisSlot            = m_eventSlots[thisSlotNum];
+    EventSlot&         thisSlot    = m_eventSlots[thisSlotNum];
     if ( !thisSlot.complete ) {
       fatal() << "The slot " << thisSlotNum << " is supposed to be a finished event but it's not" << endmsg;
       return StatusCode::FAILURE;
@@ -649,7 +649,7 @@ StatusCode AvalancheSchedulerSvc::updateStates( int si, const int algo_index, Ev
     int iSlot = thisSlotPtr->eventContext->slot();
 
     // Cache the states of the algos to improve readability and performance
-    auto& thisSlot                      = m_eventSlots[iSlot];
+    auto&                thisSlot       = m_eventSlots[iSlot];
     AlgsExecutionStates& thisAlgsStates = thisSlot.algsStates;
 
     // Perform the I->CR->DR transitions
@@ -934,8 +934,8 @@ StatusCode AvalancheSchedulerSvc::promoteToScheduled( unsigned int iAlgo, int si
   if ( m_algosInFlight == m_maxAlgosInFlight ) return StatusCode::FAILURE;
 
   const std::string& algName( index2algname( iAlgo ) );
-  IAlgorithm* ialgoPtr = nullptr;
-  StatusCode sc( m_algResourcePool->acquireAlgorithm( algName, ialgoPtr ) );
+  IAlgorithm*        ialgoPtr = nullptr;
+  StatusCode         sc( m_algResourcePool->acquireAlgorithm( algName, ialgoPtr ) );
 
   if ( sc.isSuccess() ) { // if we managed to get an algorithm instance try to schedule it
 
@@ -997,8 +997,8 @@ StatusCode AvalancheSchedulerSvc::promoteToAsyncScheduled( unsigned int iAlgo, i
   // bool IOBound = m_precSvc->isBlocking(algName);
 
   const std::string& algName( index2algname( iAlgo ) );
-  IAlgorithm* ialgoPtr = nullptr;
-  StatusCode sc( m_algResourcePool->acquireAlgorithm( algName, ialgoPtr ) );
+  IAlgorithm*        ialgoPtr = nullptr;
+  StatusCode         sc( m_algResourcePool->acquireAlgorithm( algName, ialgoPtr ) );
 
   if ( sc.isSuccess() ) { // if we managed to get an algorithm instance try to schedule it
 
@@ -1138,8 +1138,8 @@ StatusCode AvalancheSchedulerSvc::scheduleEventView( EventContext const* sourceC
                                                      EventContext* viewContext )
 {
   // Find the top-level slot, to attach the sub-slot to
-  int const topSlotIndex = sourceContext->slot();
-  EventSlot& topSlot     = m_eventSlots[topSlotIndex];
+  int const  topSlotIndex = sourceContext->slot();
+  EventSlot& topSlot      = m_eventSlots[topSlotIndex];
 
   //  Prevent view nesting - this doesn't work because EventContext is copied when passed to algorithm
   /*if ( sourceContext != topSlot.eventContext )
diff --git a/GaudiHive/src/PrecedenceRulesGraph.cpp b/GaudiHive/src/PrecedenceRulesGraph.cpp
index 5b1d6a429..148140107 100644
--- a/GaudiHive/src/PrecedenceRulesGraph.cpp
+++ b/GaudiHive/src/PrecedenceRulesGraph.cpp
@@ -136,9 +136,9 @@ namespace concurrency
     // Detach condition algorithms from the CF realm
     if ( m_conditionsRealmEnabled ) {
       SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc", false )};
-      auto& condAlgs = condSvc->condAlgs();
+      auto&             condAlgs = condSvc->condAlgs();
       for ( const auto algo : condAlgs ) {
-        auto itA = m_algoNameToAlgoNodeMap.find( algo->name() );
+        auto                        itA = m_algoNameToAlgoNodeMap.find( algo->name() );
         concurrency::AlgorithmNode* algoNode;
         if ( itA != m_algoNameToAlgoNodeMap.end() ) {
           algoNode = itA->second;
@@ -248,8 +248,8 @@ namespace concurrency
     StatusCode sc = StatusCode::SUCCESS;
 
     // Create new, or fetch existent, AlgorithmNode
-    auto& algoName = algo->name();
-    auto itA       = m_algoNameToAlgoNodeMap.find( algoName );
+    auto&                       algoName = algo->name();
+    auto                        itA      = m_algoNameToAlgoNodeMap.find( algoName );
     concurrency::AlgorithmNode* algoNode;
     if ( itA != m_algoNameToAlgoNodeMap.end() ) {
       algoNode = itA->second;
@@ -271,7 +271,7 @@ namespace concurrency
     // Attach AlgorithmNode to its CF decision hub
     auto itP = m_decisionNameToDecisionHubMap.find( parentName );
     if ( itP != m_decisionNameToDecisionHubMap.end() ) {
-      auto parentNode = itP->second;
+      auto       parentNode = itP->second;
       ON_VERBOSE verbose() << "Attaching AlgorithmNode '" << algo->name() << "' to DecisionNode '" << parentName << "'"
                            << endmsg;
 
@@ -298,7 +298,7 @@ namespace concurrency
 
     StatusCode sc;
 
-    auto itD = m_dataPathToDataNodeMap.find( dataPath );
+    auto                   itD = m_dataPathToDataNodeMap.find( dataPath );
     concurrency::DataNode* dataNode;
     if ( itD != m_dataPathToDataNodeMap.end() ) {
       dataNode = itD->second;
@@ -349,11 +349,11 @@ namespace concurrency
 
     auto& decisionHubName = decisionHubAlgo->name();
 
-    auto itP = m_decisionNameToDecisionHubMap.find( parentName );
+    auto                       itP = m_decisionNameToDecisionHubMap.find( parentName );
     concurrency::DecisionNode* parentNode;
     if ( itP != m_decisionNameToDecisionHubMap.end() ) {
-      parentNode = itP->second;
-      auto itA   = m_decisionNameToDecisionHubMap.find( decisionHubName );
+      parentNode                     = itP->second;
+      auto                       itA = m_decisionNameToDecisionHubMap.find( decisionHubName );
       concurrency::DecisionNode* decisionHubNode;
       if ( itA != m_decisionNameToDecisionHubMap.end() ) {
         decisionHubNode = itA->second;
@@ -462,7 +462,7 @@ namespace concurrency
   void PrecedenceRulesGraph::dumpControlFlow( std::ostringstream& ost, ControlFlowNode* node, const int& indent ) const
   {
     ost << std::string( indent * 2, ' ' );
-    DecisionNode* dn  = dynamic_cast<DecisionNode*>( node );
+    DecisionNode*  dn = dynamic_cast<DecisionNode*>( node );
     AlgorithmNode* an = dynamic_cast<AlgorithmNode*>( node );
     if ( dn != 0 ) {
       if ( node != m_headNode ) {
@@ -492,7 +492,7 @@ namespace concurrency
   std::string PrecedenceRulesGraph::dumpDataFlow() const
   {
 
-    const char idt[] = "      ";
+    const char         idt[] = "      ";
     std::ostringstream ost;
 
     ost << "\n" << idt << "====================================\n";
diff --git a/GaudiHive/src/PrecedenceRulesGraph.h b/GaudiHive/src/PrecedenceRulesGraph.h
index c8e1400fe..e9051dcb5 100644
--- a/GaudiHive/src/PrecedenceRulesGraph.h
+++ b/GaudiHive/src/PrecedenceRulesGraph.h
@@ -46,10 +46,10 @@ namespace precedence
     {
     }
     std::string m_name;
-    int m_index{-1};
-    int m_rank{-1};
-    int m_runtime{-1}; // ns
-    int m_eccentricity{-1};
+    int         m_index{-1};
+    int         m_rank{-1};
+    int         m_runtime{-1}; // ns
+    int         m_eccentricity{-1};
   };
 
   using PrecTrace       = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, AlgoTraceProps>;
@@ -70,9 +70,9 @@ namespace precedence
     }
 
     std::string m_name{""};
-    int m_nodeIndex{-1};
-    int m_algoIndex{-1};
-    int m_rank{-1};
+    int         m_nodeIndex{-1};
+    int         m_algoIndex{-1};
+    int         m_rank{-1};
     /// Algorithm representative behind the AlgorithmNode
     Algorithm* m_algorithm{nullptr};
 
@@ -99,7 +99,7 @@ namespace precedence
     }
 
     std::string m_name;
-    uint m_nodeIndex;
+    uint        m_nodeIndex;
 
     /// Whether all daughters will be evaluated concurrently or sequentially
     bool m_modeConcurrent;
@@ -203,7 +203,7 @@ namespace precedence
         : m_slot( slot ), m_conditionsEnabled( conditionsEnabled )
     {
       SmartIF<IMessageSvc> msgSvc{svcLocator};
-      MsgStream log{msgSvc, "EntityState.Getter"};
+      MsgStream            log{msgSvc, "EntityState.Getter"};
 
       // Figure if we can discover the data object states
       m_whiteboard = svcLocator->service<IHiveWhiteBoard>( "EventDataSvc", false );
@@ -258,15 +258,15 @@ namespace precedence
     EventSlot m_slot;
 
     SmartIF<IHiveWhiteBoard> m_whiteboard;
-    SmartIF<ICondSvc> m_condSvc;
-    bool m_conditionsEnabled{false};
+    SmartIF<ICondSvc>        m_condSvc;
+    bool                     m_conditionsEnabled{false};
   };
 
   struct StartTime : static_visitor<std::string> {
     StartTime( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot )
     {
       SmartIF<IMessageSvc> msgSvc{svcLocator};
-      MsgStream log{msgSvc, "StartTime.Getter"};
+      MsgStream            log{msgSvc, "StartTime.Getter"};
 
       // Figure if we can discover the algorithm timings
       m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
@@ -300,7 +300,7 @@ namespace precedence
 
     std::string operator()( const DataProps& ) const { return ""; }
 
-    EventSlot m_slot;
+    EventSlot             m_slot;
     SmartIF<ITimelineSvc> m_timelineSvc;
   };
 
@@ -308,7 +308,7 @@ namespace precedence
     EndTime( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot )
     {
       SmartIF<IMessageSvc> msgSvc{svcLocator};
-      MsgStream log{msgSvc, "EndTime.Getter"};
+      MsgStream            log{msgSvc, "EndTime.Getter"};
 
       // Figure if we can discover the algorithm timings
       m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
@@ -341,7 +341,7 @@ namespace precedence
 
     std::string operator()( const DataProps& ) const { return ""; }
 
-    EventSlot m_slot;
+    EventSlot             m_slot;
     SmartIF<ITimelineSvc> m_timelineSvc;
   };
 
@@ -349,7 +349,7 @@ namespace precedence
     Duration( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot )
     {
       SmartIF<IMessageSvc> msgSvc{svcLocator};
-      MsgStream log{msgSvc, "Duration.Getter"};
+      MsgStream            log{msgSvc, "Duration.Getter"};
 
       // Figure if we can discover the algorithm timings
       m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
@@ -381,7 +381,7 @@ namespace precedence
 
     std::string operator()( const DataProps& ) const { return ""; }
 
-    EventSlot m_slot;
+    EventSlot             m_slot;
     SmartIF<ITimelineSvc> m_timelineSvc;
   };
 
@@ -409,7 +409,7 @@ namespace precedence
 struct Cause {
   enum class source { Root, Task };
 
-  source m_source;
+  source      m_source;
   std::string m_sourceName;
 };
 
@@ -455,7 +455,7 @@ namespace concurrency
     /// Translation between state id and name
     std::string stateToString( const int& stateId ) const;
     unsigned int m_nodeIndex;
-    std::string m_nodeName;
+    std::string  m_nodeName;
   };
 
   class DecisionNode : public ControlFlowNode
@@ -634,7 +634,7 @@ namespace concurrency
     PrecedenceRulesGraph* m_graph;
 
   private:
-    DataObjID m_data_object_path;
+    DataObjID                   m_data_object_path;
     std::vector<AlgorithmNode*> m_producers;
     std::vector<AlgorithmNode*> m_consumers;
   };
@@ -744,7 +744,7 @@ namespace concurrency
     }
 
     /// BGL-based facilities
-    void enableAnalysis() { m_enableAnalysis = true; };
+    void         enableAnalysis() { m_enableAnalysis = true; };
     PRVertexDesc node( const std::string& ) const;
 
     /// Print out all data origins and destinations, as reflected in the EF graph
@@ -770,7 +770,7 @@ namespace concurrency
     /// Index: map of data path to DataNode
     DataNodesMap m_dataPathToDataNodeMap;
     /// Indexes: maps of algorithm's name to algorithm's inputs/outputs
-    AlgoInputsMap m_algoNameToAlgoInputsMap;
+    AlgoInputsMap  m_algoNameToAlgoInputsMap;
     AlgoOutputsMap m_algoNameToAlgoOutputsMap;
 
     /// Total number of nodes in the graph
@@ -780,7 +780,7 @@ namespace concurrency
 
     /// Service locator (needed to access the MessageSvc)
     mutable SmartIF<ISvcLocator> m_svcLocator;
-    const std::string m_name;
+    const std::string            m_name;
 
     const std::chrono::system_clock::time_point m_initTime;
 
diff --git a/GaudiKernel/GaudiKernel/AlgTool.h b/GaudiKernel/GaudiKernel/AlgTool.h
index ca63d399f..691c41130 100644
--- a/GaudiKernel/GaudiKernel/AlgTool.h
+++ b/GaudiKernel/GaudiKernel/AlgTool.h
@@ -66,14 +66,14 @@ public:
   const IInterface* parent() const override;
 
   // State machine implementation
-  StatusCode configure() override { return StatusCode::SUCCESS; }
-  StatusCode initialize() override;
-  StatusCode start() override;
-  StatusCode stop() override;
-  StatusCode finalize() override;
-  StatusCode terminate() override { return StatusCode::SUCCESS; }
-  StatusCode reinitialize() override;
-  StatusCode restart() override;
+  StatusCode                 configure() override { return StatusCode::SUCCESS; }
+  StatusCode                 initialize() override;
+  StatusCode                 start() override;
+  StatusCode                 stop() override;
+  StatusCode                 finalize() override;
+  StatusCode                 terminate() override { return StatusCode::SUCCESS; }
+  StatusCode                 reinitialize() override;
+  StatusCode                 restart() override;
   Gaudi::StateMachine::State FSMState() const override { return m_state; }
   Gaudi::StateMachine::State targetFSMState() const override { return m_targetState; }
 
@@ -294,15 +294,15 @@ public:
 private:
   typedef std::list<std::pair<InterfaceID, void*>> InterfaceList;
 
-  std::string m_type;                   ///< AlgTool type (concrete class name)
+  std::string       m_type;             ///< AlgTool type (concrete class name)
   const std::string m_name;             ///< AlgTool full name
   const IInterface* m_parent = nullptr; ///< AlgTool parent
 
-  mutable SmartIF<ISvcLocator> m_svcLocator;  ///< Pointer to Service Locator service
-  mutable SmartIF<IDataProviderSvc> m_evtSvc; ///< Event data service
-  mutable SmartIF<IToolSvc> m_ptoolSvc;       ///< Tool service
-  mutable SmartIF<IMonitorSvc> m_pMonitorSvc; ///< Online Monitoring Service
-  mutable SmartIF<IAuditorSvc> m_pAuditorSvc; ///< Auditor Service
+  mutable SmartIF<ISvcLocator>      m_svcLocator;  ///< Pointer to Service Locator service
+  mutable SmartIF<IDataProviderSvc> m_evtSvc;      ///< Event data service
+  mutable SmartIF<IToolSvc>         m_ptoolSvc;    ///< Tool service
+  mutable SmartIF<IMonitorSvc>      m_pMonitorSvc; ///< Online Monitoring Service
+  mutable SmartIF<IAuditorSvc>      m_pAuditorSvc; ///< Auditor Service
 
   InterfaceList m_interfaceList; ///< Interface list
 
@@ -321,8 +321,8 @@ private:
   Gaudi::Property<bool> m_auditorRestart{this, "AuditRestart", false, "trigger auditor on restart()"};
 
   // tools used by tool
-  mutable std::vector<IAlgTool*> m_tools;
-  mutable std::vector<BaseToolHandle*> m_toolHandles;
+  mutable std::vector<IAlgTool*>             m_tools;
+  mutable std::vector<BaseToolHandle*>       m_toolHandles;
   mutable std::vector<GaudiHandleArrayBase*> m_toolHandleArrays;
   mutable bool m_toolHandlesInit = false; /// flag indicating whether ToolHandle tools have been added to m_tools
 
diff --git a/GaudiKernel/GaudiKernel/Algorithm.h b/GaudiKernel/GaudiKernel/Algorithm.h
index d5e7a066f..1fddd8895 100644
--- a/GaudiKernel/GaudiKernel/Algorithm.h
+++ b/GaudiKernel/GaudiKernel/Algorithm.h
@@ -159,7 +159,7 @@ public:
    *  whereas "ApproxTrackFit" and "BestTrackFit" may be two instantiations
    *  of the class configured to find tracks with different fit criteria.
    */
-  const std::string& name() const override;
+  const std::string&      name() const override;
   const Gaudi::StringKey& nameKey() const override;
 
   /** The type of the algorithm object.
@@ -258,19 +258,19 @@ public:
   /** The standard Chrono & Stat service,
    *  Return a pointer to the service if present
    */
-  SmartIF<IChronoStatSvc>& chronoSvc() const;
+  SmartIF<IChronoStatSvc>&                                             chronoSvc() const;
   [[deprecated( "use chronoSvc() instead" )]] SmartIF<IChronoStatSvc>& chronoStatService() const { return chronoSvc(); }
 
   /** The standard detector data service.
    *  May not be invoked before sysInitialize() has been invoked.
    */
-  SmartIF<IDataProviderSvc>& detSvc() const;
+  SmartIF<IDataProviderSvc>&                                          detSvc() const;
   [[deprecated( "use detSvc() instead" )]] SmartIF<IDataProviderSvc>& detDataService() const { return detSvc(); }
 
   /** The standard detector data persistency conversion service.
    *  May not be invoked before sysInitialize() has been invoked.
    */
-  SmartIF<IConversionSvc>& detCnvSvc() const;
+  SmartIF<IConversionSvc>&                                             detCnvSvc() const;
   [[deprecated( "use detCnvSvc() instead" )]] SmartIF<IConversionSvc>& detDataCnvService() const { return detCnvSvc(); }
 
   /** The standard event data service.
@@ -278,13 +278,13 @@ public:
    */
   SmartIF<IDataProviderSvc>& eventSvc() const;
   /// shortcut for  method eventSvc
-  SmartIF<IDataProviderSvc>& evtSvc() const { return eventSvc(); }
+  SmartIF<IDataProviderSvc>&                                            evtSvc() const { return eventSvc(); }
   [[deprecated( "use eventSvc() instead" )]] SmartIF<IDataProviderSvc>& eventDataService() const { return eventSvc(); }
 
   /** The standard event data persistency conversion service.
    *  May not be invoked before sysInitialize() has been invoked.
    */
-  SmartIF<IConversionSvc>& eventCnvSvc() const;
+  SmartIF<IConversionSvc>&                                               eventCnvSvc() const;
   [[deprecated( "use eventCnvSvc() instead" )]] SmartIF<IConversionSvc>& eventDataCnvService() const
   {
     return eventCnvSvc();
@@ -293,13 +293,13 @@ public:
   /** The standard histogram service.
    *  May not be invoked before sysInitialize() has been invoked.
    */
-  SmartIF<IHistogramSvc>& histoSvc() const;
+  SmartIF<IHistogramSvc>&                                            histoSvc() const;
   [[deprecated( "use histoSvc() instead" )]] SmartIF<IHistogramSvc>& histogramDataService() const { return histoSvc(); }
 
   /** The standard N tuple service.
    *  Returns a pointer to the N tuple service if present.
    */
-  SmartIF<INTupleSvc>& ntupleSvc() const;
+  SmartIF<INTupleSvc>&                                             ntupleSvc() const;
   [[deprecated( "use ntupleSvc() instead" )]] SmartIF<INTupleSvc>& ntupleService() const { return ntupleSvc(); }
 
   /** The standard RandomGen service,
@@ -520,40 +520,40 @@ private:
   unsigned int maxErrors() const { return m_errorMax; }
 
 private:
-  Gaudi::StringKey m_name; ///< Algorithm's name for identification
-  std::string m_type;      ///< Algorithm's type
-  std::string m_version;   ///< Algorithm's version
-  unsigned int m_index;    ///< Algorithm's index
-  EventContext m_event_context;
+  Gaudi::StringKey        m_name;    ///< Algorithm's name for identification
+  std::string             m_type;    ///< Algorithm's type
+  std::string             m_version; ///< Algorithm's version
+  unsigned int            m_index;   ///< Algorithm's index
+  EventContext            m_event_context;
   std::vector<Algorithm*> m_subAlgms; ///< Sub algorithms
 
   // tools used by algorithm
-  mutable std::vector<IAlgTool*> m_tools;
-  mutable std::vector<BaseToolHandle*> m_toolHandles;
+  mutable std::vector<IAlgTool*>             m_tools;
+  mutable std::vector<BaseToolHandle*>       m_toolHandles;
   mutable std::vector<GaudiHandleArrayBase*> m_toolHandleArrays;
 
 private:
   template <typename IFace>
   SmartIF<IFace>& get_svc_( SmartIF<IFace>& p, const char* service_name ) const;
 
-  mutable SmartIF<IMessageSvc> m_MS;            ///< Message service
-  mutable SmartIF<IDataProviderSvc> m_EDS;      ///< Event data service
-  mutable SmartIF<IHiveWhiteBoard> m_WB;        ///< Event data service (whiteboard)
-  mutable SmartIF<IConversionSvc> m_ECS;        ///< Event conversion service
-  mutable SmartIF<IDataProviderSvc> m_DDS;      ///< Detector data service
-  mutable SmartIF<IConversionSvc> m_DCS;        ///< Detector conversion service
-  mutable SmartIF<IHistogramSvc> m_HDS;         ///< Histogram data service
-  mutable SmartIF<INTupleSvc> m_NTS;            ///< N tuple service
-  mutable SmartIF<IChronoStatSvc> m_CSS;        ///< Chrono & Stat Service
-  mutable SmartIF<IRndmGenSvc> m_RGS;           ///< Random Number Generator Service
-  mutable SmartIF<IExceptionSvc> m_EXS;         ///< Exception Handler Service
-  mutable SmartIF<IAuditorSvc> m_pAuditorSvc;   ///< Auditor Service
-  mutable SmartIF<IToolSvc> m_ptoolSvc;         ///< ToolSvc Service
-  mutable SmartIF<IMonitorSvc> m_pMonitorSvc;   ///< Online Monitoring Service
-  mutable SmartIF<IAlgContextSvc> m_contextSvc; ///< Algorithm Context Service
-
-  mutable SmartIF<ITimelineSvc> m_timelineSvc; ///< Timeline Service
-  mutable SmartIF<IAlgExecStateSvc> m_aess;    ///< Alg execution state mgr
+  mutable SmartIF<IMessageSvc>      m_MS;          ///< Message service
+  mutable SmartIF<IDataProviderSvc> m_EDS;         ///< Event data service
+  mutable SmartIF<IHiveWhiteBoard>  m_WB;          ///< Event data service (whiteboard)
+  mutable SmartIF<IConversionSvc>   m_ECS;         ///< Event conversion service
+  mutable SmartIF<IDataProviderSvc> m_DDS;         ///< Detector data service
+  mutable SmartIF<IConversionSvc>   m_DCS;         ///< Detector conversion service
+  mutable SmartIF<IHistogramSvc>    m_HDS;         ///< Histogram data service
+  mutable SmartIF<INTupleSvc>       m_NTS;         ///< N tuple service
+  mutable SmartIF<IChronoStatSvc>   m_CSS;         ///< Chrono & Stat Service
+  mutable SmartIF<IRndmGenSvc>      m_RGS;         ///< Random Number Generator Service
+  mutable SmartIF<IExceptionSvc>    m_EXS;         ///< Exception Handler Service
+  mutable SmartIF<IAuditorSvc>      m_pAuditorSvc; ///< Auditor Service
+  mutable SmartIF<IToolSvc>         m_ptoolSvc;    ///< ToolSvc Service
+  mutable SmartIF<IMonitorSvc>      m_pMonitorSvc; ///< Online Monitoring Service
+  mutable SmartIF<IAlgContextSvc>   m_contextSvc;  ///< Algorithm Context Service
+
+  mutable SmartIF<ITimelineSvc>     m_timelineSvc; ///< Timeline Service
+  mutable SmartIF<IAlgExecStateSvc> m_aess;        ///< Alg execution state mgr
 
   SmartIF<ISvcLocator> m_pSvcLocator; ///< Pointer to service locator service
 
@@ -563,7 +563,7 @@ protected:
 
 private:
   // Properties
-  Gaudi::Property<int> m_outputLevel{this, "OutputLevel", MSG::NIL, "output level"};
+  Gaudi::Property<int>  m_outputLevel{this, "OutputLevel", MSG::NIL, "output level"};
   Gaudi::Property<bool> m_isEnabled{this, "Enable", true, "should the algorithm be executed or not"};
 
   Gaudi::Property<unsigned int> m_errorMax{this, "ErrorMax", 1, "[[deprecated]] max number of errors"};
@@ -607,7 +607,7 @@ private:
 
   Gaudi::StateMachine::State m_state       = Gaudi::StateMachine::CONFIGURED; ///< Algorithm has been initialized flag
   Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::CONFIGURED; ///< Algorithm has been initialized flag
-  bool m_isFinalized;                                                         ///< Algorithm has been finalized flag
+  bool                       m_isFinalized;                                   ///< Algorithm has been finalized flag
 
   /// implementation of service method
   StatusCode service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const;
diff --git a/GaudiKernel/GaudiKernel/Converter.h b/GaudiKernel/GaudiKernel/Converter.h
index d9c962fde..9949eb0a6 100644
--- a/GaudiKernel/GaudiKernel/Converter.h
+++ b/GaudiKernel/GaudiKernel/Converter.h
@@ -11,7 +11,7 @@
 
 // Forward declarations
 class IMessageSvc;
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 
 /** @class Converter Converter.h GaudiKernel/Converter.h
 
@@ -144,8 +144,8 @@ public:
 
 private:
   friend std::ostream& operator<<( std::ostream&, const ConverterID& );
-  long m_stype;
-  CLID m_clid;
+  long                 m_stype;
+  CLID                 m_clid;
 };
 
 inline std::ostream& operator<<( std::ostream& s, const ConverterID& id )
diff --git a/GaudiKernel/GaudiKernel/DataObject.h b/GaudiKernel/GaudiKernel/DataObject.h
index 762a2fd01..12fc14f0c 100644
--- a/GaudiKernel/GaudiKernel/DataObject.h
+++ b/GaudiKernel/GaudiKernel/DataObject.h
@@ -14,7 +14,7 @@
 class IOpaqueAddress;
 class StreamBuffer;
 class LinkManager;
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 
 // Definition of the CLID for this class
 static const CLID CLID_DataObject = 1;
diff --git a/GaudiKernel/GaudiKernel/DataSvc.h b/GaudiKernel/GaudiKernel/DataSvc.h
index 628800983..655f856e7 100644
--- a/GaudiKernel/GaudiKernel/DataSvc.h
+++ b/GaudiKernel/GaudiKernel/DataSvc.h
@@ -53,7 +53,7 @@ protected:
   /// Pointer to incident service
   SmartIF<IIncidentSvc> m_incidentSvc = nullptr;
 
-  Gaudi::Property<CLID> m_rootCLID{this, "RootCLID", 110 /*CLID_Event*/, "CLID of root entry"};
+  Gaudi::Property<CLID>        m_rootCLID{this, "RootCLID", 110 /*CLID_Event*/, "CLID of root entry"};
   Gaudi::Property<std::string> m_rootName{this, "RootName", "/Event", "name of root entry"};
   Gaudi::Property<bool> m_forceLeaves{this, "ForceLeaves", false, "force creation of default leaves on registerObject"};
   Gaudi::Property<std::vector<std::string>> m_inhibitPathes{this, "InhibitPathes", {}, "inhibited leaves"};
@@ -69,7 +69,7 @@ protected:
   /// Items to be pre-loaded
   LoadItems m_preLoads;
   /// Pointer to root entry
-  DataSvcHelpers::RegistryEntry* m_root = nullptr;
+  std::unique_ptr<DataSvcHelpers::RegistryEntry> m_root;
   /// Map with object paths to be inhibited from loading
   DataSvcHelpers::InhibitMap* m_inhibitMap = nullptr;
 
@@ -310,15 +310,14 @@ public:
   /// Standard Destructor
   ~DataSvc() override;
 
-private:
-  /// Fake copy constructor (never implemented).
+  /// copy constructor disabled
   DataSvc( const DataSvc& ) = delete;
-  /// Fake assignment operator (never implemented).
+  /// assignment operator disabled
   DataSvc& operator=( const DataSvc& ) = delete;
 
 protected:
   /// Check if root path is valid
-  bool checkRoot() { return 0 != m_root; }
+  bool checkRoot() { return LIKELY( m_root != nullptr ); }
 
   /** Retrieve customizable data loader according to registry entry to be
    *  retrieved
@@ -347,11 +346,6 @@ protected:
     *
     * @return Object corresponding to the specified leaf
     */
-  DataObject* handleDataFault( IRegistry* pReg, boost::string_ref path = "" );
-
-private:
-  StatusCode i_retrieveEntry( DataSvcHelpers::RegistryEntry* parentObj, boost::string_ref path,
-                              DataSvcHelpers::RegistryEntry*& pEntry );
-  DataObject* i_handleDataFault( IRegistry* pReg, boost::string_ref path = boost::string_ref{} );
+  DataObject* handleDataFault( IRegistry* pReg, boost::string_ref path = {} );
 };
 #endif // GAUDIKERNEL_DATASVC_H
diff --git a/GaudiKernel/GaudiKernel/GenericAddress.h b/GaudiKernel/GaudiKernel/GenericAddress.h
index 1f2d7ef8c..7af0dd1c8 100644
--- a/GaudiKernel/GaudiKernel/GenericAddress.h
+++ b/GaudiKernel/GaudiKernel/GenericAddress.h
@@ -6,7 +6,7 @@
 #include "GaudiKernel/Kernel.h"
 
 // Forward declarations
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 
 /** @class GenericAddress GenericAddress.h GaudiKernel/GenericAddress.h
 
diff --git a/GaudiKernel/GaudiKernel/IDataManagerSvc.h b/GaudiKernel/GaudiKernel/IDataManagerSvc.h
index 240f605a1..337e39da9 100644
--- a/GaudiKernel/GaudiKernel/IDataManagerSvc.h
+++ b/GaudiKernel/GaudiKernel/IDataManagerSvc.h
@@ -18,7 +18,7 @@ class IDataStoreAgent;
 // Opaque addresses
 class IOpaqueAddress;
 // Registry entry definition
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 // Data provider svc
 class IDataProviderSvc;
 
diff --git a/GaudiKernel/GaudiKernel/IDataProviderSvc.h b/GaudiKernel/GaudiKernel/IDataProviderSvc.h
index 63dcaa3cb..cf8f99a65 100644
--- a/GaudiKernel/GaudiKernel/IDataProviderSvc.h
+++ b/GaudiKernel/GaudiKernel/IDataProviderSvc.h
@@ -11,7 +11,7 @@
 // Forward declarations
 class DataObject;
 class IOpaqueAddress;
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 class DataStoreItem;
 
 /** @class IDataProviderSvc IDataProviderSvc.h GaudiKernel/IDataProviderSvc.h
diff --git a/GaudiKernel/GaudiKernel/IDataStoreAgent.h b/GaudiKernel/GaudiKernel/IDataStoreAgent.h
index 56a05490e..bbe2fcd79 100644
--- a/GaudiKernel/GaudiKernel/IDataStoreAgent.h
+++ b/GaudiKernel/GaudiKernel/IDataStoreAgent.h
@@ -5,7 +5,7 @@
 #include "GaudiKernel/Kernel.h"
 
 // Forward declarations:
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 
 /** @class IDataStoreAgent IDataStoreAgent.h GaudiKernel/IDataStoreAgent.h
 
diff --git a/GaudiKernel/GaudiKernel/IHistogramSvc.h b/GaudiKernel/GaudiKernel/IHistogramSvc.h
index e79344868..ff1b62976 100644
--- a/GaudiKernel/GaudiKernel/IHistogramSvc.h
+++ b/GaudiKernel/GaudiKernel/IHistogramSvc.h
@@ -3,6 +3,7 @@
 
 // Include files
 #include "GaudiKernel/IDataProviderSvc.h"
+#include "GaudiKernel/IRegistry.h"
 #include "GaudiKernel/IService.h"
 #include <iostream>
 #include <string>
diff --git a/GaudiKernel/GaudiKernel/IOpaqueAddress.h b/GaudiKernel/GaudiKernel/IOpaqueAddress.h
index 3260a1f03..93858e56d 100644
--- a/GaudiKernel/GaudiKernel/IOpaqueAddress.h
+++ b/GaudiKernel/GaudiKernel/IOpaqueAddress.h
@@ -9,7 +9,7 @@
 #include "GaudiKernel/Kernel.h"
 
 // forward declarations
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 
 /** @class IOpaqueAddress IOpaqueAddress.h GaudiKernel/IOpaqueAddress.h
 
diff --git a/GaudiKernel/GaudiKernel/IRegistry.h b/GaudiKernel/GaudiKernel/IRegistry.h
index a6afe2bd1..e26c88e11 100644
--- a/GaudiKernel/GaudiKernel/IRegistry.h
+++ b/GaudiKernel/GaudiKernel/IRegistry.h
@@ -2,57 +2,7 @@
 #define GAUDIKERNEL_IREGISTRY_H
 
 // Include files
-#include "GaudiKernel/Kernel.h"
-#include <string>
+#include "GaudiKernel/RegistryEntry.h"
 
-// forward declarations
-class DataObject;
-class IOpaqueAddress;
-class IDataProviderSvc;
-
-/** @class IRegistry IRegistry.h GaudiKernel/IRegistry.h
-
-    The IRegistry represents the entry door to the environment
-    any data object residing in a transient data store is embedded.
-
-    Split from directory browsing (which is now sub-classed), providing
-    a light-weight interface to differing registry mechanism.
-
-*/
-class GAUDI_API IRegistry
-{
-public:
-  /// Type definitions
-  /// Name type
-  typedef std::string name_type;
-  /// Identifier Key type
-  typedef std::string id_type;
-
-  /// destructor
-  virtual ~IRegistry() = default;
-
-  /// Add reference to object
-  virtual unsigned long addRef() = 0;
-
-  /// release reference to object
-  virtual unsigned long release() = 0;
-
-  /// Name of the directory (or key)
-  virtual const name_type& name() const = 0;
-
-  /// Full identifier (or key)
-  virtual const id_type& identifier() const = 0;
-
-  /// Retrieve pointer to Transient Store
-  virtual IDataProviderSvc* dataSvc() const = 0;
-
-  /// Retrieve object behind the link
-  virtual DataObject* object() const = 0;
-
-  /// Retrieve opaque storage address
-  virtual IOpaqueAddress* address() const = 0;
-
-  /// Set/Update Opaque storage address
-  virtual void setAddress( IOpaqueAddress* pAddress ) = 0;
-};
+using IRegistry = DataSvcHelpers::RegistryEntry;
 #endif // KERNEL_IREGISTRY_H
diff --git a/GaudiKernel/GaudiKernel/LinkManager.h b/GaudiKernel/GaudiKernel/LinkManager.h
index 106506c5f..d49351753 100644
--- a/GaudiKernel/GaudiKernel/LinkManager.h
+++ b/GaudiKernel/GaudiKernel/LinkManager.h
@@ -18,7 +18,7 @@ class IOpaqueAddress;
   *
   *  @author M.Frank
   */
-class GAUDI_API LinkManager
+class GAUDI_API LinkManager final
 {
 
 public:
@@ -61,7 +61,7 @@ public:
     void setObject( const DataObject* pObject ) { m_pObject = const_cast<DataObject*>( pObject ); }
     /// Const access to data object
     const DataObject* object() const { return m_pObject; }
-    DataObject* object() { return m_pObject; }
+    DataObject*       object() { return m_pObject; }
     /// Access to path of object
     const std::string& path() const { return m_path; }
     /// Link identifier
@@ -82,21 +82,20 @@ private:
   //           4) revoke friendship.
   //         Now we're at stage 1...
   friend class MergeEventAlg;
-  ///@ TODO: replace by std::vector<std::unique_ptr<Link>> once
-  ///        ROOT does 'automatic' schema conversion from T* to
-  ///        std::unique_ptr<T>...
-  ///        Or, even better, just std::vector<Link>, given that
+  ///@ TODO: replace by std::vector<Link> given that
   ///        Link is barely larger than a pointer (40 vs. 8 bytes)
   ///        -- but that requires more invasive schema evolution.
   ///
   /// The vector containing all links which are non-tree like
-  mutable std::vector<Link*> m_linkVector;
+  mutable std::vector<std::unique_ptr<Link>> m_linkVector;
 
 public:
   /// Standard Constructor
   LinkManager() = default;
   /// Standard Destructor
-  virtual ~LinkManager();
+  //// -- this _must_ be virtual, as the 'old' data has a vtbl pointer, and
+  ///     we have to maintain the memory layout... even if this class is 'final'
+  virtual ~LinkManager() = default;
   /// Static instantiation
   static LinkManager* newInstance();
   /// Assign new instantiator
diff --git a/GaudiKernel/GaudiKernel/RegistryEntry.h b/GaudiKernel/GaudiKernel/RegistryEntry.h
index 4239b2b86..2b220df1f 100644
--- a/GaudiKernel/GaudiKernel/RegistryEntry.h
+++ b/GaudiKernel/GaudiKernel/RegistryEntry.h
@@ -2,22 +2,22 @@
 #define GAUDIKERNEL_REGISTRYENTRY_H
 
 // STL include files
+#include <memory>
 #include <vector>
 
 // Framework include files
-#include "GaudiKernel/IRegistry.h"
 #include "GaudiKernel/Kernel.h"
 #include "GaudiKernel/StatusCode.h"
 #include <boost/utility/string_ref.hpp>
 
 // Forward declarations
 class DataSvc;
-// DP add this fwd decl for thread safety
 class TsDataSvc;
 class DataObject;
 class IDataProviderSvc;
 class IOpaqueAddress;
 class IDataStoreAgent;
+class StatusCode;
 
 namespace DataSvcHelpers
 {
@@ -34,22 +34,38 @@ namespace DataSvcHelpers
    * @author Markus Frank
    * @author Sebastien Ponce
    */
-  class GAUDI_API RegistryEntry final : public IRegistry
+  class GAUDI_API RegistryEntry final
   {
-  private:
-    /// Definition of datastore type
-    typedef std::vector<IRegistry*> Store;
-
   public:
     friend class ::DataSvc;
-    // DP add friend class: the thread safe version of the DataSvc
     friend class ::TsDataSvc;
-    /// Iterator definition
-    typedef Store::const_iterator Iterator;
+
+    /// Standard Constructor
+    RegistryEntry( std::string path, RegistryEntry* parent = nullptr );
+    /// Destructor
+    ~RegistryEntry();
+
+    /// Retrieve name of the entry
+    const std::string& name() const { return m_path; }
+    /// Full identifier (or key)
+    const std::string& identifier() const { return m_fullpath; }
+    /// Retrieve pointer to Transient Store
+    IDataProviderSvc* dataSvc() const { return m_pDataProviderSvc; }
+    /// Retrive object behind the link
+    DataObject* object() const { return m_pObject; }
+    /// Retrieve opaque storage address
+    IOpaqueAddress* address() const { return m_pAddress; }
+    /// Pointer to parent directory entry
+    RegistryEntry* parent() const { return m_pParent; }
+    /// Set/Update Opaque address
+    void setAddress( IOpaqueAddress* pAddress );
+
+    /// Return starting point for container iteration
+    auto begin() const { return m_store.begin(); }
+    /// Return end elemtn if the container
+    auto end() const { return m_store.end(); }
 
   private:
-    /// Reference counter
-    unsigned long m_refCount = 0;
     /// Is the link soft or hard?
     bool m_isSoft = false;
     /// String containing full path of the object (volatile)
@@ -65,26 +81,23 @@ namespace DataSvcHelpers
     /// Pointer to hosting transient store
     IDataProviderSvc* m_pDataProviderSvc = nullptr;
     /// Store of leaves
-    Store m_store;
+    std::vector<std::unique_ptr<RegistryEntry>> m_store;
 
   private:
-    /** The following entries serve two aspects:
-      1) They are faster for recursive calls, because they are non-virtual
-      2) They can be re-used for the non-const entry points using a
+    /** The following entries serve one aspect:
+      1) They can be re-used for the non-const entry points using a
          const_cast of the result.
     */
     /// Recursive helper to assemble the full path name of the entry
     void assemblePath( std::string& buffer ) const;
     /// Internal method to retrieve data directory
-    IRegistry* i_find( const IRegistry* pDirectory ) const;
+    RegistryEntry* i_find( const RegistryEntry* pDirectory ) const;
     /// Internal method to retrieve data directory
     RegistryEntry* i_find( boost::string_ref path ) const;
     /// Internal method to locate object entry
     RegistryEntry* i_find( const DataObject* pObject ) const;
     /// Internal method to create entries
-    RegistryEntry* i_create( std::string name );
-    /// Internal method to add entries
-    long i_add( RegistryEntry* entry );
+    std::unique_ptr<RegistryEntry> i_create( std::string name );
     /// Set new parent pointer
     void setParent( RegistryEntry* pParent );
     /// Set the transient data store
@@ -104,45 +117,19 @@ namespace DataSvcHelpers
     /// Initialize link as soft link
     void makeSoft( IOpaqueAddress* pAddress );
 
-  public:
-    /// Standard Constructor
-    RegistryEntry( std::string path, RegistryEntry* parent = nullptr );
-    /// Standard Destructor
-    ~RegistryEntry() override;
-    /// IInterface implementation: Reference the object
-    unsigned long release() override;
-    /// IInterface implementation: Dereference the object
-    unsigned long addRef() override { return ++m_refCount; }
-    /// Retrieve name of the entry
-    const std::string& name() const override { return m_path; }
-    /// Full identifier (or key)
-    const std::string& identifier() const override { return m_fullpath; }
-    /// Retrieve pointer to Transient Store
-    IDataProviderSvc* dataSvc() const override { return m_pDataProviderSvc; }
-    /// Retrive object behind the link
-    DataObject* object() const override { return m_pObject; }
-    /// Retrieve opaque storage address
-    IOpaqueAddress* address() const override { return m_pAddress; }
-    /// Pointer to parent directory entry
-    IRegistry* parent() const { return m_pParent; }
+  private:
     /// Is the link soft or hard
     bool isSoft() const { return m_isSoft; }
     /// Access the leaves of the object
-    const Store& leaves() const { return m_store; }
+    const auto& leaves() const { return m_store; }
     /// Return the size of the container(=number of objects)
     int size() const { return m_store.size(); }
     /// Simple check if the Container is empty
     bool isEmpty() const { return m_store.size() == 0; }
-    /// Return starting point for container iteration
-    Iterator begin() const { return m_store.begin(); }
-    /// Return end elemtn if the container
-    Iterator end() const { return m_store.end(); }
     /// Try to find an object identified by its pointer
-    IRegistry* find( const IRegistry* obj ) const { return i_find( obj ); }
+    RegistryEntry* find( const RegistryEntry* obj ) const { return i_find( obj ); }
     /// Try to find an object identified by its relative name to the directory
-    IRegistry* find( boost::string_ref path ) const { return i_find( path ); }
-    /// Set/Update Opaque address
-    void setAddress( IOpaqueAddress* pAddress ) override;
+    RegistryEntry* find( boost::string_ref path ) const { return i_find( path ); }
     /// Set/Update object address
     void setObject( DataObject* obj );
 
@@ -153,11 +140,9 @@ namespace DataSvcHelpers
     /// Remove an entry from the store
     StatusCode remove( boost::string_ref name );
     /// Add object to the container
-    long add( IRegistry* obj );
+    long add( std::unique_ptr<RegistryEntry> obj );
     /// Remove an object from the container
-    long remove( IRegistry* obj );
-    /// Delete all contained elements
-    long deleteElements();
+    long remove( RegistryEntry* obj );
     /// traverse data tree
     StatusCode traverseTree( IDataStoreAgent* pAgent, int level = 0 );
   };
diff --git a/GaudiKernel/GaudiKernel/SmartDataObjectPtr.h b/GaudiKernel/GaudiKernel/SmartDataObjectPtr.h
index da73c42c9..c05b3cdbf 100644
--- a/GaudiKernel/GaudiKernel/SmartDataObjectPtr.h
+++ b/GaudiKernel/GaudiKernel/SmartDataObjectPtr.h
@@ -11,7 +11,7 @@
 // Forward declarations
 class SmartDataObjectPtr;
 class IDataProviderSvc;
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 class DataObject;
 
 /** @class SmartDataObjectPtr SmartDataObjectPtr.h GaudiKernel/SmartDataObjectPtr.h
diff --git a/GaudiKernel/GaudiKernel/TsDataSvc.h b/GaudiKernel/GaudiKernel/TsDataSvc.h
index e67b1e498..90cdf9268 100644
--- a/GaudiKernel/GaudiKernel/TsDataSvc.h
+++ b/GaudiKernel/GaudiKernel/TsDataSvc.h
@@ -3,9 +3,12 @@
 
 // Include files
 #include "GaudiKernel/DataStoreItem.h"
+#include "GaudiKernel/IConversionSvc.h"
 #include "GaudiKernel/IDataManagerSvc.h"
 #include "GaudiKernel/IDataProviderSvc.h"
+#include "GaudiKernel/IIncidentSvc.h"
 #include "GaudiKernel/Service.h"
+#include "GaudiKernel/SmartIF.h"
 
 // External libraries
 #include "tbb/recursive_mutex.h"
@@ -18,8 +21,6 @@ namespace
 }
 
 // Forward declarations
-// Incident service
-class IIncidentSvc;
 // Generic address
 class IOpaqueAddress;
 // Generic interface to data object class
@@ -63,11 +64,11 @@ public:
 
 protected:
   /// Pointer to data loader service
-  IConversionSvc* m_dataLoader = nullptr;
+  SmartIF<IConversionSvc> m_dataLoader = nullptr;
   /// Pointer to incident service
-  IIncidentSvc* m_incidentSvc = nullptr;
+  SmartIF<IIncidentSvc> m_incidentSvc = nullptr;
 
-  Gaudi::Property<CLID> m_rootCLID{this, "RootCLID", 110 /*CLID_Event*/, "CLID of root entry"};
+  Gaudi::Property<CLID>        m_rootCLID{this, "RootCLID", 110 /*CLID_Event*/, "CLID of root entry"};
   Gaudi::Property<std::string> m_rootName{this, "RootName", "/Event", "name of root entry"};
   Gaudi::Property<bool> m_forceLeaves{this, "ForceLeaves", false, "force creation of default leaves on registerObject"};
   Gaudi::Property<std::vector<std::string>> m_inhibitPathes{this, "InhibitPathes", {}, "inhibited leaves"};
@@ -83,7 +84,7 @@ protected:
   /// Items to be pre-loaded
   LoadItems m_preLoads;
   /// Pointer to root entry
-  DataSvcHelpers::RegistryEntry* m_root = nullptr;
+  std::unique_ptr<DataSvcHelpers::RegistryEntry> m_root;
   /// Map with object paths to be inhibited from loading
   DataSvcHelpers::InhibitMap* m_inhibitMap = nullptr;
 
@@ -332,7 +333,7 @@ private:
 
 protected:
   /// Check if root path is valid
-  bool checkRoot() { return 0 != m_root; }
+  bool checkRoot() { return LIKELY( m_root != nullptr ); }
 
   /** Retrieve customizable data loader according to registry entry to be
    *  retrieved
diff --git a/GaudiKernel/src/Lib/DataSvc.cpp b/GaudiKernel/src/Lib/DataSvc.cpp
index c07170fc9..3abc55793 100644
--- a/GaudiKernel/src/Lib/DataSvc.cpp
+++ b/GaudiKernel/src/Lib/DataSvc.cpp
@@ -63,19 +63,12 @@ namespace
   std::string to_string( boost::string_ref sr ) { return {sr.data(), sr.size()}; }
 }
 
-// If you absolutely need optimization: switch off dynamic_cast.
-// This improves access to the data store roughly by 10 %
-// for balanced trees.
-//
-// M.Frank
-#define CAST_REGENTRY( x, y ) dynamic_cast<x>( y )
-//#define CAST_REGENTRY(x,y) (x)(y)
 typedef DataSvcHelpers::RegistryEntry RegEntry;
 
 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
 
-#define DEBMSG ON_DEBUG debug()
+#define DEBMSG ON_DEBUG   debug()
 #define VERMSG ON_VERBOSE verbose()
 
 /** IDataManagerSvc: Remove all data objects below the sub tree
@@ -84,9 +77,9 @@ typedef DataSvcHelpers::RegistryEntry RegEntry;
 StatusCode DataSvc::clearSubTree( boost::string_ref sub_tree_path )
 {
   DataObject* pObject = nullptr;
-  StatusCode status   = findObject( sub_tree_path, pObject );
+  StatusCode  status  = findObject( sub_tree_path, pObject );
   if ( !status.isSuccess() ) return status;
-  RegEntry* node_entry = CAST_REGENTRY( RegEntry*, pObject->registry() );
+  RegEntry* node_entry = pObject->registry();
   if ( !node_entry ) return Status::INVALID_OBJECT;
   RegEntry* parent = node_entry->parentEntry();
   if ( !parent ) return Status::INVALID_PARENT;
@@ -100,7 +93,7 @@ StatusCode DataSvc::clearSubTree( boost::string_ref sub_tree_path )
 StatusCode DataSvc::clearSubTree( DataObject* pObject )
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  RegEntry* entry = CAST_REGENTRY( RegEntry*, pObject->registry() );
+  RegEntry* entry = pObject->registry();
   if ( !entry ) return Status::INVALID_OBJECT;
   RegEntry* parent = entry->parentEntry();
   if ( !parent ) return Status::INVALID_PARENT;
@@ -112,8 +105,7 @@ StatusCode DataSvc::clearSubTree( DataObject* pObject )
 StatusCode DataSvc::clearStore()
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  m_root->release();
-  m_root = nullptr;
+  m_root.reset();
   return StatusCode::SUCCESS;
 }
 
@@ -122,8 +114,8 @@ StatusCode DataSvc::clearStore()
  */
 StatusCode DataSvc::traverseSubTree( boost::string_ref sub_tree_path, IDataStoreAgent* pAgent )
 {
-  DataObject* pO    = nullptr;
-  StatusCode status = findObject( sub_tree_path, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = findObject( sub_tree_path, pO );
   return status.isSuccess() ? traverseSubTree( pO, pAgent ) : status;
 }
 
@@ -131,7 +123,7 @@ StatusCode DataSvc::traverseSubTree( boost::string_ref sub_tree_path, IDataStore
 StatusCode DataSvc::traverseSubTree( DataObject* pObject, IDataStoreAgent* pAgent )
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  RegEntry* entry = CAST_REGENTRY( RegEntry*, pObject->registry() );
+  RegEntry* entry = pObject->registry();
   if ( !entry ) return Status::INVALID_OBJECT;
   return entry->traverseTree( pAgent );
 }
@@ -161,7 +153,9 @@ StatusCode DataSvc::setRoot( std::string root_path, DataObject* pRootObj )
 StatusCode DataSvc::i_setRoot( std::string root_path, DataObject* pRootObj )
 {
   if ( pRootObj ) {
-    m_root = new RegEntry( std::move( root_path ) );
+    m_root.release(); // FIXME: this leaks, but it is what the orignal code
+                      // did implicitly...
+    m_root = std::make_unique<RegEntry>( std::move( root_path ) );
     m_root->makeHard( pRootObj );
     m_root->setDataSvc( this );
     // No done with GaudiHive. preLoad().ignore();
@@ -187,7 +181,9 @@ StatusCode DataSvc::setRoot( std::string root_path, IOpaqueAddress* pRootAddr )
 StatusCode DataSvc::i_setRoot( std::string root_path, IOpaqueAddress* pRootAddr )
 {
   if ( pRootAddr ) {
-    m_root = new RegEntry( std::move( root_path ) );
+    m_root.release(); // FIXME: this leaks, but it is what the orignal code
+                      // did implicitly...
+    m_root = std::make_unique<RegEntry>( std::move( root_path ) );
     m_root->makeHard( pRootAddr );
     m_root->setDataSvc( this );
     // Not done with GaudiHive. preLoad().ignore();
@@ -213,9 +209,8 @@ StatusCode DataSvc::objectParent( const DataObject* pObject, IRegistry*& refpPar
 StatusCode DataSvc::objectParent( const IRegistry* pRegistry, IRegistry*& refpParent )
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  const RegEntry* node_entry = CAST_REGENTRY( const RegEntry*, pRegistry );
-  if ( !node_entry ) return Status::INVALID_OBJECT;
-  refpParent = node_entry->parent();
+  if ( !pRegistry ) return Status::INVALID_OBJECT;
+  refpParent = pRegistry->parent();
   return StatusCode::SUCCESS;
 }
 
@@ -232,9 +227,11 @@ StatusCode DataSvc::objectLeaves( const DataObject* pObject, std::vector<IRegist
 StatusCode DataSvc::objectLeaves( const IRegistry* pRegistry, std::vector<IRegistry*>& leaves )
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  const RegEntry* node_entry = CAST_REGENTRY( const RegEntry*, pRegistry );
-  if ( !node_entry ) return Status::INVALID_OBJECT;
-  leaves = node_entry->leaves();
+  if ( !pRegistry ) return Status::INVALID_OBJECT;
+  const auto& l = pRegistry->leaves();
+  leaves.clear();
+  leaves.reserve( l.size() );
+  std::transform( begin( l ), end( l ), std::back_inserter( leaves ), []( const auto& i ) { return i.get(); } );
   return StatusCode::SUCCESS;
 }
 
@@ -242,7 +239,7 @@ StatusCode DataSvc::objectLeaves( const IRegistry* pRegistry, std::vector<IRegis
 StatusCode DataSvc::registerAddress( boost::string_ref fullPath, IOpaqueAddress* pAddress )
 {
   if ( fullPath.empty() ) return Status::INVALID_OBJ_PATH;
-  return registerAddress( fullPath.front() != SEPARATOR ? m_root : nullptr, fullPath, pAddress );
+  return registerAddress( fullPath.front() != SEPARATOR ? m_root.get() : nullptr, fullPath, pAddress );
 }
 
 ///  IDataManagerSvc: Register object address with the data store.
@@ -260,37 +257,36 @@ StatusCode DataSvc::registerAddress( IRegistry* parentObj, boost::string_ref obj
 
   if ( !parentObj ) {
     if ( objPath.front() != SEPARATOR ) {
-      return registerAddress( m_root, objPath, pAddress );
+      return registerAddress( m_root.get(), objPath, pAddress );
     }
     auto sep = find( objPath, SEPARATOR, 1 );
     if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) != m_rootName.value() ) {
       return Status::INVALID_PARENT;
     }
-    return registerAddress( m_root, objPath.substr( sep ), pAddress );
+    return registerAddress( m_root.get(), objPath.substr( sep ), pAddress );
   }
   if ( objPath.front() != SEPARATOR ) {
     return registerAddress( parentObj, char( SEPARATOR ) + objPath, pAddress );
   }
-  RegEntry* par_entry = CAST_REGENTRY( RegEntry*, parentObj );
-  if ( !par_entry ) return Status::INVALID_PARENT;
+  if ( !parentObj ) return Status::INVALID_PARENT;
 
   auto sep = objPath.rfind( SEPARATOR );
   if ( sep > 0 && sep != boost::string_ref::npos ) {
-    auto p_path       = objPath.substr( 0, sep );
-    auto o_path       = objPath.substr( sep );
-    RegEntry* p_entry = par_entry->findLeaf( p_path );
+    auto      p_path  = objPath.substr( 0, sep );
+    auto      o_path  = objPath.substr( sep );
+    RegEntry* p_entry = parentObj->findLeaf( p_path );
     // Create default object leafs if the
     // intermediate nodes are not present
     if ( !p_entry && m_forceLeaves ) {
       DataObject* pLeaf = createDefaultObject();
-      StatusCode sc     = registerObject( par_entry->identifier(), p_path, pLeaf );
+      StatusCode  sc    = registerObject( parentObj->identifier(), p_path, pLeaf );
       if ( sc.isFailure() ) delete pLeaf;
-      p_entry = par_entry->findLeaf( p_path );
+      p_entry = parentObj->findLeaf( p_path );
     }
     if ( !p_entry ) return Status::INVALID_PARENT;
     return registerAddress( p_entry, o_path, pAddress );
   }
-  StatusCode status = par_entry->add( to_string( objPath ), pAddress );
+  StatusCode status = parentObj->add( to_string( objPath ), pAddress );
   return status.isSuccess() ? status : Status::DOUBL_OBJ_PATH;
 }
 
@@ -298,7 +294,7 @@ StatusCode DataSvc::registerAddress( IRegistry* parentObj, boost::string_ref obj
 StatusCode DataSvc::unregisterAddress( boost::string_ref fullPath )
 {
   if ( fullPath.empty() ) return Status::INVALID_OBJ_PATH;
-  return unregisterAddress( fullPath.front() != SEPARATOR ? m_root : nullptr, fullPath );
+  return unregisterAddress( fullPath.front() != SEPARATOR ? m_root.get() : nullptr, fullPath );
 }
 
 ///  IDataManagerSvc: Unregister object address from the data store.
@@ -314,25 +310,24 @@ StatusCode DataSvc::unregisterAddress( IRegistry* pParent, boost::string_ref obj
   if ( objPath.empty() ) return Status::INVALID_OBJ_PATH;
 
   if ( !pParent ) {
-    if ( objPath.front() != SEPARATOR ) return unregisterAddress( m_root, objPath );
+    if ( objPath.front() != SEPARATOR ) return unregisterAddress( m_root.get(), objPath );
     auto sep = find( objPath, SEPARATOR, 1 );
     if ( sep != boost::string_ref::npos && objPath.substr( 0, sep ) == m_rootName ) {
-      return unregisterAddress( m_root, objPath.substr( sep ) );
+      return unregisterAddress( m_root.get(), objPath.substr( sep ) );
     }
     return Status::INVALID_PARENT;
   }
   if ( objPath.front() != SEPARATOR ) {
     return unregisterAddress( pParent, char( SEPARATOR ) + objPath );
   }
-  RegEntry* node_entry = CAST_REGENTRY( RegEntry*, pParent );
-  if ( node_entry ) {
-    RegEntry* leaf_entry = node_entry->findLeaf( objPath );
+  if ( pParent ) {
+    RegEntry* leaf_entry = pParent->findLeaf( objPath );
     if ( leaf_entry ) {
       auto sep = objPath.rfind( SEPARATOR );
       if ( sep > 0 && sep != boost::string_ref::npos ) {
         return unregisterAddress( leaf_entry->parent(), objPath.substr( sep ) );
       }
-      StatusCode status = node_entry->remove( objPath );
+      StatusCode status = pParent->remove( objPath );
       if ( status.isSuccess() ) return status;
     }
   }
@@ -348,8 +343,8 @@ StatusCode DataSvc::registerObject( boost::string_ref fullPath, DataObject* pObj
 /// Register object with the data store.
 StatusCode DataSvc::registerObject( boost::string_ref parentPath, boost::string_ref objPath, DataObject* pObject )
 {
-  DataObject* pO    = nullptr;
-  StatusCode status = retrieveObject( parentPath, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = retrieveObject( parentPath, pO );
   if ( !status.isSuccess() && m_forceLeaves ) {
     pO     = createDefaultObject();
     status = registerObject( parentPath, pO );
@@ -387,26 +382,26 @@ StatusCode DataSvc::registerObject( DataObject* parentObj, boost::string_ref obj
     }
     return Status::INVALID_OBJ_PATH;
   }
-  RegEntry* node_entry = CAST_REGENTRY( RegEntry*, parentObj->registry() );
+  RegEntry* node_entry = parentObj->registry();
   if ( node_entry ) {
     StatusCode status = Status::INVALID_PARENT;
-    auto sep          = find( objPath, SEPARATOR, 1 );
+    auto       sep    = find( objPath, SEPARATOR, 1 );
     if ( sep != boost::string_ref::npos ) {
-      auto p_path         = objPath.substr( 0, sep );
-      auto o_path         = objPath.substr( sep );
+      auto      p_path    = objPath.substr( 0, sep );
+      auto      o_path    = objPath.substr( sep );
       RegEntry* par_entry = node_entry->findLeaf( p_path );
       // Create default object leafs if the
       // intermediate nodes are not present
       if ( !par_entry && m_forceLeaves ) {
         DataObject* pLeaf = createDefaultObject();
-        StatusCode sc     = registerObject( parentObj, p_path, pLeaf );
+        StatusCode  sc    = registerObject( parentObj, p_path, pLeaf );
         if ( !sc.isSuccess() ) delete pLeaf;
         par_entry = node_entry->findLeaf( p_path );
       } else if ( par_entry && !par_entry->object() ) {
-        status = i_retrieveEntry( node_entry, p_path, par_entry );
+        status = retrieveEntry( node_entry, p_path, par_entry );
         if ( !status.isSuccess() && !par_entry->address() && m_forceLeaves ) {
           DataObject* pLeaf = createDefaultObject();
-          StatusCode sc     = registerObject( parentObj, p_path, pLeaf );
+          StatusCode  sc    = registerObject( parentObj, p_path, pLeaf );
           if ( !sc.isSuccess() ) delete pLeaf;
           par_entry = node_entry->findLeaf( p_path );
         }
@@ -445,9 +440,9 @@ StatusCode DataSvc::registerObject( DataObject* parentObj, boost::string_ref obj
 StatusCode DataSvc::unregisterObject( boost::string_ref fullPath )
 {
   DataObject* pObject = nullptr;
-  StatusCode status   = findObject( fullPath, pObject );
+  StatusCode  status  = findObject( fullPath, pObject );
   if ( status.isFailure() ) return status;
-  RegEntry* pEntry = CAST_REGENTRY( RegEntry*, pObject->registry() );
+  RegEntry* pEntry = pObject->registry();
   if ( !pEntry ) return Status::INVALID_ROOT;
   if ( !pEntry->isEmpty() ) return Status::DIR_NOT_EMPTY;
   RegEntry* pParent = pEntry->parentEntry();
@@ -460,8 +455,8 @@ StatusCode DataSvc::unregisterObject( boost::string_ref fullPath )
 /// Unregister object from the data store.
 StatusCode DataSvc::unregisterObject( boost::string_ref parentPath, boost::string_ref objPath )
 {
-  DataObject* pO    = nullptr;
-  StatusCode status = findObject( parentPath, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = findObject( parentPath, pO );
   return status.isSuccess() ? unregisterObject( pO, objPath ) : status;
 }
 
@@ -488,28 +483,20 @@ StatusCode DataSvc::unregisterObject( DataObject* pObject )
 /// Unregister object from the data store.
 StatusCode DataSvc::unregisterObject( DataObject* pParentObj, boost::string_ref objectPath )
 {
-  if ( checkRoot() ) {
-    try {
-      RegEntry* parent = CAST_REGENTRY( RegEntry*, pParentObj->registry() );
-      if ( parent ) {
-        RegEntry* entry = parent->findLeaf( objectPath );
-        if ( entry ) {
-          if ( entry->isEmpty() ) {
-            if ( entry->object() ) {
-              entry->object()->addRef();
-            }
-            parent->remove( entry );
-            return StatusCode::SUCCESS;
-          }
-          return Status::DIR_NOT_EMPTY;
-        }
-        return Status::INVALID_OBJECT;
-      }
-    } catch ( ... ) {
+  if ( !checkRoot() ) return Status::INVALID_ROOT;
+  try {
+    RegEntry* parent = pParentObj->registry();
+    if ( parent ) {
+      RegEntry* entry = parent->findLeaf( objectPath );
+      if ( !entry ) return Status::INVALID_OBJECT;
+      if ( !entry->isEmpty() ) return Status::DIR_NOT_EMPTY;
+      if ( entry->object() ) entry->object()->addRef();
+      parent->remove( entry );
+      return StatusCode::SUCCESS;
     }
-    return Status::INVALID_PARENT;
+  } catch ( ... ) {
   }
-  return Status::INVALID_ROOT;
+  return Status::INVALID_PARENT;
 }
 
 /// Unregister object from the data store.
@@ -520,12 +507,8 @@ StatusCode DataSvc::unregisterObject( DataObject* pParentObj, int item )
 
 /** Invoke data fault handling if enabled
   */
-DataObject* DataSvc::handleDataFault( IRegistry* pReg, boost::string_ref path )
-{
-  return i_handleDataFault( pReg, path );
-}
 
-DataObject* DataSvc::i_handleDataFault( IRegistry* pReg, boost::string_ref path )
+DataObject* DataSvc::handleDataFault( IRegistry* pReg, boost::string_ref path )
 {
   if ( m_enableFaultHdlr ) {
     IRegistry* pLeaf = nullptr;
@@ -549,9 +532,7 @@ DataObject* DataSvc::i_handleDataFault( IRegistry* pReg, boost::string_ref path
       m_incidentSvc->fireIncident( incident );
       pLeaf = m_root->findLeaf( p );
     }
-    if ( pLeaf ) {
-      return pLeaf->object();
-    }
+    if ( pLeaf ) return pLeaf->object();
   }
   return nullptr;
 }
@@ -570,7 +551,7 @@ StatusCode DataSvc::loadObject( IRegistry* pRegistry )
  */
 StatusCode DataSvc::loadObject( IConversionSvc* pLoader, IRegistry* pRegistry )
 {
-  StatusCode status   = Status::INVALID_OBJ_ADDR;
+  StatusCode  status  = Status::INVALID_OBJ_ADDR;
   DataObject* pObject = nullptr;
   if ( !pLoader ) { // Precondition: Data loader must be present
     return handleDataFault( pRegistry ) ? StatusCode::SUCCESS : StatusCode( Status::NO_DATA_LOADER );
@@ -602,35 +583,26 @@ StatusCode DataSvc::loadObject( IConversionSvc* pLoader, IRegistry* pRegistry )
 
       VERMSG << "Object " << pRegistry->identifier() << " created" << endmsg;
 
-      RegEntry* pEntry = CAST_REGENTRY( RegEntry*, pRegistry );
-      pEntry->setObject( pObject );
+      pRegistry->setObject( pObject );
 
       VERMSG << "Filling object " << pRegistry->identifier() << endmsg;
       status = pLoader->fillObjRefs( pAddress, pObject );
     }
   } catch ( const GaudiException& exc ) {
-    if ( handleDataFault( pRegistry ) ) {
-      return StatusCode::SUCCESS;
-    }
+    if ( handleDataFault( pRegistry ) ) return StatusCode::SUCCESS;
     throw GaudiException( "GaudiException in loadObject() " + pRegistry->identifier(), name(), StatusCode::FAILURE,
                           exc );
   } catch ( const std::exception& x ) {
-    if ( handleDataFault( pRegistry ) ) {
-      return StatusCode::SUCCESS;
-    }
+    if ( handleDataFault( pRegistry ) ) return StatusCode::SUCCESS;
     throw GaudiException( "std::exception in loadObject() " + pRegistry->identifier() + ": " +
                               System::typeinfoName( typeid( x ) ) + ", " + x.what(),
                           name(), StatusCode::FAILURE );
   } catch ( ... ) {
-    if ( handleDataFault( pRegistry ) ) {
-      return StatusCode::SUCCESS;
-    }
+    if ( handleDataFault( pRegistry ) ) return StatusCode::SUCCESS;
     throw GaudiException( "UNKN exception in loadObject() " + pRegistry->identifier(), name(), StatusCode::FAILURE );
   }
   if ( !status.isSuccess() ) {
-    if ( handleDataFault( pRegistry ) ) {
-      return StatusCode::SUCCESS;
-    }
+    if ( handleDataFault( pRegistry ) ) return StatusCode::SUCCESS;
   }
   ON_VERBOSE if ( status.isSuccess() )
   {
@@ -641,32 +613,27 @@ StatusCode DataSvc::loadObject( IConversionSvc* pLoader, IRegistry* pRegistry )
 
 /// Retrieve registry entry from store
 StatusCode DataSvc::retrieveEntry( RegEntry* parentObj, boost::string_ref path, RegEntry*& pEntry )
-{
-  return i_retrieveEntry( parentObj, path, pEntry );
-}
-
-StatusCode DataSvc::i_retrieveEntry( RegEntry* parentObj, boost::string_ref path, RegEntry*& pEntry )
 {
   // A.Valassi 16.08.2001 avoid core dump if store is empty
   if ( !checkRoot() ) return StatusCode( Status::INVALID_ROOT, true );
 
   static const auto empty = boost::string_ref{};
-  auto sep                = find( path, SEPARATOR, 1 );
+  auto              sep   = find( path, SEPARATOR, 1 );
   pEntry                  = nullptr;
 
   if ( !parentObj ) {
     if ( path.empty() || path == m_rootName ) {
-      parentObj = m_root;
+      parentObj = m_root.get();
       path      = empty;
     } else if ( path.front() != SEPARATOR ) {
-      parentObj = m_root;
+      parentObj = m_root.get();
     } else if ( sep != boost::string_ref::npos ) {
       if ( !m_root->object() ) {
-        RegEntry* r = nullptr;
-        auto status = i_retrieveEntry( m_root, empty, r );
+        RegEntry* r      = nullptr;
+        auto      status = retrieveEntry( m_root.get(), empty, r );
         if ( !status.isSuccess() ) return status;
       }
-      parentObj = m_root;
+      parentObj = m_root.get();
       path      = path.substr( sep );
     } else {
       return Status::INVALID_OBJ_PATH;
@@ -680,12 +647,12 @@ StatusCode DataSvc::i_retrieveEntry( RegEntry* parentObj, boost::string_ref path
       status = loadObject( parentObj );
       if ( !status.isSuccess() ) return status;
     }
-    auto p_path          = path.substr( 0, sep );
+    auto      p_path     = path.substr( 0, sep );
     RegEntry* root_entry = parentObj->findLeaf( p_path );
     if ( !root_entry && m_enableFaultHdlr ) {
       // If not even the parent is there, an incident
       // to load the parent must be fired...
-      i_handleDataFault( parentObj, p_path );
+      handleDataFault( parentObj, p_path );
       root_entry = parentObj->findLeaf( p_path );
     }
     if ( root_entry ) {
@@ -695,10 +662,8 @@ StatusCode DataSvc::i_retrieveEntry( RegEntry* parentObj, boost::string_ref path
         status = loadObject( root_entry );
         if ( !status.isSuccess() ) return status;
       }
-      if ( root_entry->isSoft() ) {
-        root_entry = CAST_REGENTRY( RegEntry*, pO->registry() );
-      }
-      return i_retrieveEntry( root_entry, path.substr( sep ), pEntry );
+      if ( root_entry->isSoft() ) root_entry = pO->registry();
+      return retrieveEntry( root_entry, path.substr( sep ), pEntry );
     }
     return status;
   } else if ( path.empty() ) {
@@ -712,7 +677,7 @@ StatusCode DataSvc::i_retrieveEntry( RegEntry* parentObj, boost::string_ref path
     pEntry = parentObj->findLeaf( path );
     // If no registry entry was found, trigger incident for action-on-demand
     if ( !pEntry && m_enableFaultHdlr ) {
-      i_handleDataFault( parentObj, path );
+      handleDataFault( parentObj, path );
       pEntry = ( path.empty() ? parentObj : parentObj->findLeaf( path ) );
     }
   }
@@ -736,9 +701,9 @@ StatusCode DataSvc::i_retrieveEntry( RegEntry* parentObj, boost::string_ref path
 /// Retrieve object identified by its directory from the data store.
 StatusCode DataSvc::retrieveObject( IRegistry* pRegistry, boost::string_ref path, DataObject*& pObject )
 {
-  pObject          = nullptr;
-  RegEntry *result = nullptr, *parent = CAST_REGENTRY( RegEntry *, pRegistry );
-  StatusCode status                 = i_retrieveEntry( parent, path, result );
+  pObject                           = nullptr;
+  RegEntry*  result                 = nullptr;
+  StatusCode status                 = retrieveEntry( pRegistry, path, result );
   if ( status.isSuccess() ) pObject = result->object();
   return status;
 }
@@ -754,7 +719,7 @@ StatusCode DataSvc::retrieveObject( boost::string_ref fullPath, DataObject*& pOb
 StatusCode DataSvc::retrieveObject( boost::string_ref parentPath, boost::string_ref objectPath, DataObject*& pObject )
 {
   DataObject* parent = nullptr;
-  StatusCode status  = retrieveObject( parentPath, parent );
+  StatusCode  status = retrieveObject( parentPath, parent );
   return status.isSuccess() ? retrieveObject( parent, objectPath, pObject ) : status;
 }
 
@@ -781,8 +746,8 @@ StatusCode DataSvc::retrieveObject( DataObject* parentObj, int item, DataObject*
 StatusCode DataSvc::findObject( IRegistry* pRegistry, boost::string_ref path, DataObject*& pObject )
 {
   pObject              = nullptr;
-  IRegistry* pReg      = ( pRegistry ? pRegistry : m_root );
-  RegEntry* root_entry = CAST_REGENTRY( RegEntry*, pReg );
+  RegEntry* pReg       = ( pRegistry ? pRegistry : m_root.get() );
+  RegEntry* root_entry = pReg;
   if ( root_entry ) {
     if ( !path.empty() ) pReg = root_entry->find( path );
     if ( !pReg ) return Status::INVALID_OBJ_PATH;
@@ -808,7 +773,7 @@ StatusCode DataSvc::findObject( boost::string_ref path, DataObject*& pObject )
 StatusCode DataSvc::findObject( boost::string_ref parentPath, boost::string_ref objectPath, DataObject*& pObject )
 {
   DataObject* parent = nullptr;
-  StatusCode status  = findObject( parentPath, parent );
+  StatusCode  status = findObject( parentPath, parent );
   return status.isSuccess() ? findObject( parent, objectPath, pObject ) : status;
 }
 
@@ -834,8 +799,8 @@ StatusCode DataSvc::findObject( DataObject* parentObj, boost::string_ref path, D
 /// Update object.
 StatusCode DataSvc::updateObject( boost::string_ref updatePath )
 {
-  DataObject* pO    = nullptr;
-  StatusCode status = findObject( updatePath, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = findObject( updatePath, pO );
   return status.isSuccess() ? updateObject( pO ) : retrieveObject( updatePath, pO );
 }
 
@@ -898,7 +863,7 @@ StatusCode DataSvc::updateObject( DataObject* toUpdate )
 StatusCode DataSvc::updateObject( boost::string_ref parentPath, boost::string_ref updatePath )
 {
   DataObject* pParent = nullptr;
-  StatusCode status   = findObject( parentPath, pParent );
+  StatusCode  status  = findObject( parentPath, pParent );
   return status.isSuccess() ? updateObject( pParent, updatePath ) : status;
 }
 
@@ -906,7 +871,7 @@ StatusCode DataSvc::updateObject( boost::string_ref parentPath, boost::string_re
 StatusCode DataSvc::updateObject( DataObject* parent, boost::string_ref updatePath )
 {
   DataObject* pObject = nullptr;
-  StatusCode status   = findObject( parent, updatePath, pObject );
+  StatusCode  status  = findObject( parent, updatePath, pObject );
   return status.isSuccess() ? updateObject( pObject ) : status;
 }
 
@@ -915,19 +880,18 @@ StatusCode DataSvc::linkObject( IRegistry* from, boost::string_ref objPath, Data
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
   try {
-    RegEntry* from_entry = CAST_REGENTRY( RegEntry*, from );
-    if ( from_entry ) {
+    if ( from ) {
       // First check if both objects are already registered to the store
       RegEntry* to_entry = m_root->findLeaf( to );
       if ( !to_entry ) return Status::INVALID_OBJECT;
       auto sep = objPath.rfind( SEPARATOR );
       if ( sep > 0 && sep != boost::string_ref::npos ) { // in case the objPath is a sub-directory itself
         DataObject* pO = nullptr;
-        StatusCode sc  = retrieveObject( from, objPath.substr( 0, sep ), pO );
+        StatusCode  sc = retrieveObject( from, objPath.substr( 0, sep ), pO );
         return sc.isSuccess() ? linkObject( pO->registry(), objPath.substr( sep ), to ) : sc;
       }
       // Now register the soft link
-      StatusCode status = from_entry->add( to_string( objPath ), to, true );
+      StatusCode status = from->add( to_string( objPath ), to, true );
       return status.isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
     }
   } catch ( ... ) {
@@ -949,8 +913,8 @@ StatusCode DataSvc::linkObject( boost::string_ref fullPath, DataObject* to )
 /// Add a link to another object.
 StatusCode DataSvc::linkObject( boost::string_ref from, boost::string_ref objPath, DataObject* to )
 {
-  DataObject* pO    = nullptr;
-  StatusCode status = retrieveObject( from, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = retrieveObject( from, pO );
   return status.isSuccess() ? linkObject( pO->registry(), objPath, to ) : status;
 }
 
@@ -959,9 +923,7 @@ StatusCode DataSvc::linkObject( DataObject* from, boost::string_ref objPath, Dat
 {
   if ( from ) {
     IRegistry* from_entry = from->registry();
-    if ( from_entry ) {
-      return linkObject( from_entry, objPath, to );
-    }
+    if ( from_entry ) return linkObject( from_entry, objPath, to );
   }
   return Status::INVALID_PARENT;
 }
@@ -971,15 +933,14 @@ StatusCode DataSvc::unlinkObject( IRegistry* from, boost::string_ref objPath )
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
   try {
-    RegEntry* from_entry = CAST_REGENTRY( RegEntry*, from );
-    if ( from_entry ) {
+    if ( from ) {
       auto sep = objPath.rfind( SEPARATOR );
       if ( sep > 0 && sep != boost::string_ref::npos ) { // in case the objPath is a sub-directory itself
         DataObject* pO = nullptr;
-        StatusCode sc  = findObject( from, objPath.substr( 0, sep ), pO );
+        StatusCode  sc = findObject( from, objPath.substr( 0, sep ), pO );
         return sc.isSuccess() ? unlinkObject( pO->registry(), objPath.substr( sep ) ) : sc;
       }
-      StatusCode status = from_entry->remove( objPath );
+      StatusCode status = from->remove( objPath );
       if ( status.isSuccess() ) return status;
       return Status::INVALID_OBJ_PATH;
     }
@@ -1003,7 +964,7 @@ StatusCode DataSvc::unlinkObject( boost::string_ref fullPath )
 StatusCode DataSvc::unlinkObject( boost::string_ref from, boost::string_ref objPath )
 {
   DataObject* pObject = nullptr;
-  StatusCode status   = findObject( from, pObject );
+  StatusCode  status  = findObject( from, pObject );
   return status.isSuccess() ? unlinkObject( pObject->registry(), objPath ) : status;
 }
 
@@ -1054,11 +1015,11 @@ StatusCode DataSvc::preLoad( int depth, int load_depth, DataObject* pObject )
 {
   // unused:  StatusCode sc = StatusCode::FAILURE;
   if ( pObject && depth++ < load_depth ) {
-    RegEntry* dir = CAST_REGENTRY( RegEntry*, pObject->registry() );
+    RegEntry* dir = pObject->registry();
     if ( dir ) {
       for ( const auto& i : *dir ) {
-        DataObject* pObj  = nullptr;
-        StatusCode status = retrieveObject( pObject, i->name(), pObj );
+        DataObject* pObj   = nullptr;
+        StatusCode  status = retrieveObject( pObject, i->name(), pObj );
         if ( status.isSuccess() && depth < load_depth ) {
           preLoad( depth, load_depth, pObj ).ignore();
         }
@@ -1073,8 +1034,8 @@ StatusCode DataSvc::preLoad()
 {
   DataObject* pObj = nullptr;
   for ( const auto& i : m_preLoads ) {
-    StatusCode sc  = retrieveObject( i.path(), pObj );
-    int load_depth = i.depth();
+    StatusCode sc         = retrieveObject( i.path(), pObj );
+    int        load_depth = i.depth();
     if ( sc.isSuccess() && load_depth > 1 ) {
       preLoad( 1, load_depth, pObj ).ignore();
     }
diff --git a/GaudiKernel/src/Lib/LinkManager.cpp b/GaudiKernel/src/Lib/LinkManager.cpp
index 2bfd84fc0..b3aeb87f9 100644
--- a/GaudiKernel/src/Lib/LinkManager.cpp
+++ b/GaudiKernel/src/Lib/LinkManager.cpp
@@ -5,12 +5,6 @@
 
 static LinkManager* ( *s_newInstance )() = nullptr;
 
-/// destructor
-LinkManager::~LinkManager()
-{
-  for ( auto& i : m_linkVector ) delete i;
-}
-
 /// Access to the object's address from the link
 IOpaqueAddress* LinkManager::Link::address()
 {
@@ -30,29 +24,25 @@ LinkManager* LinkManager::newInstance() { return s_newInstance ? ( *s_newInstanc
 /// Retrieve symbolic link identified by ID
 LinkManager::Link* LinkManager::link( long id )
 {
-  return ( 0 <= id && (unsigned)id < m_linkVector.size() ) ? m_linkVector[id] : nullptr;
+  return ( 0 <= id && (unsigned)id < m_linkVector.size() ) ? m_linkVector[id].get() : nullptr;
 }
 
 /// Retrieve symbolic link identified by Object pointer
 LinkManager::Link* LinkManager::link( const DataObject* pObject )
 {
-  if ( pObject ) {
-    for ( auto& i : m_linkVector ) {
-      if ( i->object() == pObject ) return i;
-    }
-  }
-  return nullptr;
+  if ( !pObject ) return nullptr;
+  auto i = std::find_if( begin( m_linkVector ), end( m_linkVector ),
+                         [&]( const auto& p ) { return p->object() == pObject; } );
+  return i != end( m_linkVector ) ? i->get() : nullptr;
 }
 
 /// Retrieve symbolic link identified by Object path
 LinkManager::Link* LinkManager::link( const std::string& path )
 {
-  if ( 0 != path.length() ) {
-    for ( auto& i : m_linkVector ) {
-      if ( i->path() == path ) return i;
-    }
-  }
-  return nullptr;
+  if ( path.empty() ) return nullptr;
+  auto i =
+      std::find_if( begin( m_linkVector ), end( m_linkVector ), [&]( const auto& p ) { return p->path() == path; } );
+  return i != end( m_linkVector ) ? i->get() : nullptr;
 }
 
 /// Add link by object reference and path string
@@ -78,45 +68,30 @@ long LinkManager::addLink( const std::string& path, const DataObject* pObject )
 // Remove a link by object reference
 long LinkManager::removeLink( const DataObject* pObject ) const
 {
-  long n = 0;
-  for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
-    if ( ( *i )->object() == pObject ) {
-      delete *i;
-      m_linkVector.erase( i );
-      return n;
-    }
-    ++n;
-  }
-  return INVALID;
+  auto i = std::find_if( begin( m_linkVector ), end( m_linkVector ),
+                         [&]( const auto& p ) { return p->object() == pObject; } );
+  if ( i == end( m_linkVector ) ) return INVALID;
+  i = m_linkVector.erase( i );
+  return std::distance( begin( m_linkVector ), i );
 }
 
 // Remove a link by object reference
 long LinkManager::removeLink( const std::string& path ) const
 {
-  long n = 0;
-  for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
-    if ( ( *i )->path() == path ) {
-      delete *i;
-      m_linkVector.erase( i );
-      return n;
-    }
-    n++;
-  }
-  return INVALID;
+  auto i =
+      std::find_if( begin( m_linkVector ), end( m_linkVector ), [&]( const auto& p ) { return p->path() == path; } );
+  if ( i == end( m_linkVector ) ) return INVALID;
+  i = m_linkVector.erase( i );
+  return std::distance( begin( m_linkVector ), i );
 }
 
 // Remove a link by object reference
 long LinkManager::removeLink( long id ) const
 {
   auto i = std::next( m_linkVector.begin(), id );
-  delete *i;
   m_linkVector.erase( i );
   return id;
 }
 
 /// Remove all possibly existing symbolic links
-void LinkManager::clearLinks()
-{
-  for ( auto& i : m_linkVector ) delete i;
-  m_linkVector.clear();
-}
+void LinkManager::clearLinks() { m_linkVector.clear(); }
diff --git a/GaudiKernel/src/Lib/RegistryEntry.cpp b/GaudiKernel/src/Lib/RegistryEntry.cpp
index ab1822ab9..9a7de18c5 100644
--- a/GaudiKernel/src/Lib/RegistryEntry.cpp
+++ b/GaudiKernel/src/Lib/RegistryEntry.cpp
@@ -7,19 +7,11 @@
 //  Description: implementation of the Transient data store
 //
 //	Author     : M.Frank
-//  History    :
-// +---------+----------------------------------------------+---------
-// |    Date |                 Comment                      | Who
-// +---------+----------------------------------------------+---------
-// | 29/10/98| Initial version                              | MF
-// | 03/02/99| Protect dynamic_cast with try-catch clauses  | MF
-// +---------+----------------------------------------------+---------
 //
 //====================================================================
-#define DATASVC_REGISTRYENTRY_CPP
-
 // STL include files
 #include <algorithm>
+#include <cassert>
 
 // Interfaces
 #include "GaudiKernel/IDataStoreAgent.h"
@@ -28,32 +20,80 @@
 // Framework include files
 #include "GaudiKernel/DataObject.h"
 #include "GaudiKernel/RegistryEntry.h"
+#include "GaudiKernel/StatusCode.h"
+namespace
+{
+  constexpr char SEPARATOR{'/'};
 
-// If you absolutely need optimization: switch off dynamic_cast.
-// This improves access to the data store roughly by more than 10 %
-// for balanced trees.
-//
-// M.Frank
-//
-#define CAST_REGENTRY( x, y ) dynamic_cast<x>( y )
-//#define CAST_REGENTRY(x,y) (x)(y)
-constexpr char SEPARATOR{'/'};
+  template <typename Op>
+  auto compare_with( boost::string_ref sr )
+  {
+    // skip leading '/' in comparison
+    return [sr]( const auto& arg ) {
+      assert( !!arg );
+      assert( !arg->name().empty() );
+      assert( arg->name().front() == SEPARATOR );
+      return Op{}( arg->name().compare( 1, std::string::npos, sr.data(), sr.size() ), 0 );
+    };
+  }
+
+  namespace details_log
+  {
+    template <typename C>
+    auto find_( C& c, boost::string_ref arg )
+    {
+      if ( arg.front() == SEPARATOR ) arg.remove_prefix( 1 );
+      auto i = std::partition_point( begin( c ), end( c ), compare_with<std::less<>>( arg ) );
+      return ( i == end( c ) || compare_with<std::equal_to<>>( arg )( *i ) ) ? i : end( c );
+    }
+
+    template <typename C, typename E>
+    void insert_( C& c, E entry )
+    {
+      const auto& name = entry->name();
+      c.insert( std::partition_point( begin( c ), end( c ), [&name]( const auto& arg ) { return arg->name() < name; } ),
+                std::move( entry ) );
+    }
+  }
+
+  namespace details_linear
+  {
+    template <typename C>
+    auto find_( C& c, boost::string_ref arg )
+    {
+      if ( arg.front() == SEPARATOR ) arg.remove_prefix( 1 );
+      return std::find_if( begin( c ), end( c ), compare_with<std::equal_to<>>( arg ) );
+    }
+
+    template <typename C, typename E>
+    void insert_( C& c, E entry )
+    {
+      c.push_back( std::move( entry ) );
+    }
+  }
+
+  template <typename C>
+  auto find_( C& c, const IRegistry* obj )
+  {
+    return std::find_if( begin( c ), end( c ), [obj]( const auto& j ) { return j.get() == obj; } );
+  }
+
+  using namespace details_linear;
+}
 
 /// Standard Constructor
 DataSvcHelpers::RegistryEntry::RegistryEntry( std::string path, RegistryEntry* parent )
     : m_path( std::move( path ) ), m_pParent( parent )
 {
-  std::string::size_type sep = m_path.rfind( SEPARATOR );
+  auto sep = m_path.rfind( SEPARATOR );
   if ( m_path.front() != SEPARATOR ) m_path.insert( 0, 1, SEPARATOR );
   if ( sep != std::string::npos ) m_path.erase( 0, sep );
   assemblePath( m_fullpath );
-  addRef();
 }
 
 /// Standard destructor
 DataSvcHelpers::RegistryEntry::~RegistryEntry()
 {
-  deleteElements();
   if ( m_pObject ) {
     if ( !m_isSoft ) m_pObject->setRegistry( nullptr );
     m_pObject->release();
@@ -64,14 +104,6 @@ DataSvcHelpers::RegistryEntry::~RegistryEntry()
   }
 }
 
-/// Release entry
-unsigned long DataSvcHelpers::RegistryEntry::release()
-{
-  unsigned long cnt = --m_refCount;
-  if ( !m_refCount ) delete this;
-  return cnt;
-}
-
 /// Set new parent pointer
 void DataSvcHelpers::RegistryEntry::setParent( RegistryEntry* pParent )
 {
@@ -139,12 +171,8 @@ void DataSvcHelpers::RegistryEntry::setObject( DataObject* pObject )
 long DataSvcHelpers::RegistryEntry::remove( IRegistry* obj )
 {
   try {
-    RegistryEntry* pEntry = dynamic_cast<RegistryEntry*>( obj );
-    auto i                = std::remove( std::begin( m_store ), std::end( m_store ), pEntry );
-    if ( i != std::end( m_store ) ) {
-      pEntry->release();
-      m_store.erase( i, std::end( m_store ) );
-    }
+    auto i = find_( m_store, obj );
+    if ( i != m_store.end() ) m_store.erase( i );
   } catch ( ... ) {
   }
   return m_store.size();
@@ -153,51 +181,36 @@ long DataSvcHelpers::RegistryEntry::remove( IRegistry* obj )
 /// Remove entry from data store
 StatusCode DataSvcHelpers::RegistryEntry::remove( boost::string_ref nam )
 {
-  if ( nam.front() == SEPARATOR ) nam.remove_prefix( 1 );
-  auto i = std::find_if( m_store.begin(), m_store.end(), [&]( const auto* entry ) {
-    // skip leading SEPARATOR
-    return entry->name().compare( 1, std::string::npos, nam.data(), nam.size() ) == 0;
-  } );
+  auto i = find_( m_store, nam );
   // if the requested object is not present, this is an error....
   if ( i == m_store.end() ) return StatusCode::FAILURE;
-  remove( *i );
+  m_store.erase( i );
   return StatusCode::SUCCESS;
 }
 
 /// Internal method to add entries
-DataSvcHelpers::RegistryEntry* DataSvcHelpers::RegistryEntry::i_create( std::string nam )
+std::unique_ptr<DataSvcHelpers::RegistryEntry> DataSvcHelpers::RegistryEntry::i_create( std::string nam )
 {
   if ( nam.front() != SEPARATOR ) nam.insert( 0, 1, SEPARATOR );
   // if this object is already present, this is an error....
-  auto not_present =
-      std::none_of( std::begin( m_store ), std::end( m_store ), [&]( IRegistry* i ) { return nam == i->name(); } );
-  return not_present ? new RegistryEntry( std::move( nam ), this ) : nullptr;
-}
-
-/// Add object to the container
-long DataSvcHelpers::RegistryEntry::add( IRegistry* obj )
-{
-  RegistryEntry* pEntry = CAST_REGENTRY( RegistryEntry*, obj );
-  return i_add( pEntry );
+  return find_( m_store, nam ) == m_store.end() ? std::make_unique<RegistryEntry>( std::move( nam ), this )
+                                                : std::unique_ptr<RegistryEntry>{};
 }
 
 /// Add object to the container
-long DataSvcHelpers::RegistryEntry::i_add( RegistryEntry* pEntry )
+long DataSvcHelpers::RegistryEntry::add( std::unique_ptr<RegistryEntry> pEntry )
 {
-  // TODO: if this is the sole place where items are added to m_store,
-  //      and we know here that they must be RegisteryEntry, can we
-  //      drop the dynamic_cast every where else???
-  // TODO: if so, can we also change m_store to be std::vector<RegistryEntry*>
-  //      instead
-  // TODO: if so, can we not make it std::vector<RegistryEntry> instead?
+  // TODO: can we change m_store to std::vector<RegistryEntry> instead?
   // TODO: if so, should make sure that a RegistryEntry can be std::move'ed
+  // No: the address of the registry entry is assumed to be stable ;-(
+  //     it is eg. exposed in the call to 'setRegistry' below
   try {
     pEntry->setDataSvc( m_pDataProviderSvc );
-    m_store.push_back( pEntry );
     pEntry->setParent( this );
     if ( !pEntry->isSoft() && pEntry->address() ) {
-      pEntry->address()->setRegistry( pEntry );
+      pEntry->address()->setRegistry( pEntry.get() );
     }
+    insert_( m_store, std::move( pEntry ) );
   } catch ( ... ) {
   }
   return m_store.size();
@@ -206,42 +219,28 @@ long DataSvcHelpers::RegistryEntry::i_add( RegistryEntry* pEntry )
 /// Add entry to the current data store item
 StatusCode DataSvcHelpers::RegistryEntry::add( std::string name, DataObject* pObject, bool is_soft )
 {
-  RegistryEntry* entry = i_create( std::move( name ) );
+  auto entry = i_create( std::move( name ) );
   if ( !entry ) return StatusCode::FAILURE;
   ( is_soft ) ? entry->makeSoft( pObject ) : entry->makeHard( pObject );
-  i_add( entry );
+  add( std::move( entry ) );
   return StatusCode::SUCCESS;
 }
 
 /// Add entry to the current data store item
 StatusCode DataSvcHelpers::RegistryEntry::add( std::string name, IOpaqueAddress* pAddress, bool is_soft )
 {
-  RegistryEntry* entry = i_create( std::move( name ) );
+  auto entry = i_create( std::move( name ) );
   if ( !entry ) return StatusCode::FAILURE;
   ( is_soft ) ? entry->makeSoft( pAddress ) : entry->makeHard( pAddress );
-  i_add( entry );
+  add( std::move( entry ) );
   return StatusCode::SUCCESS;
 }
 
-/// Delete recursively all elements pending from the current store item
-long DataSvcHelpers::RegistryEntry::deleteElements()
-{
-  for ( auto& i : m_store ) {
-    RegistryEntry* entry = CAST_REGENTRY( RegistryEntry*, i );
-    if ( entry ) {
-      entry->deleteElements();
-      entry->release();
-    }
-  }
-  m_store.erase( m_store.begin(), m_store.end() );
-  return 0;
-}
-
 /// Try to find an object identified by its pointer
 IRegistry* DataSvcHelpers::RegistryEntry::i_find( const IRegistry* obj ) const
 {
-  auto i = std::find( m_store.begin(), m_store.end(), obj );
-  return ( i != m_store.end() ) ? ( *i ) : nullptr;
+  auto i = find_( m_store, obj );
+  return ( i != m_store.end() ) ? i->get() : nullptr;
 }
 
 /// Find identified leaf in this registry node
@@ -259,15 +258,11 @@ DataSvcHelpers::RegistryEntry* DataSvcHelpers::RegistryEntry::i_find( boost::str
     } else {
       path.clear();
     }
-    auto i = std::find_if( std::begin( m_store ), std::end( m_store ),
-                           [&]( const auto& reg ) { return cpath == boost::string_ref{reg->name()}.substr( 1 ); } );
-    if ( i != std::end( m_store ) ) {
-      RegistryEntry* regEnt = CAST_REGENTRY( RegistryEntry*, *i );
-      return path.empty() ? regEnt : regEnt->i_find( path );
-    }
+    auto i = find_( m_store, cpath );
+    if ( i != m_store.end() ) return path.empty() ? i->get() : ( *i )->i_find( path );
     // If this node is "/NodeA", this part allows to find "/NodeA/NodeB" as
     // our "/NodeB" child.
-    if ( cpath != boost::string_ref{m_path}.substr( 1 ) ) break;
+    if ( !compare_with<std::equal_to<>>( cpath )( this ) ) break;
   }
   return nullptr;
 }
@@ -278,16 +273,15 @@ DataSvcHelpers::RegistryEntry* DataSvcHelpers::RegistryEntry::i_find( const Data
   if ( key ) {
     if ( key == m_pObject ) return const_cast<RegistryEntry*>( this );
     // Look in the immediate level:
-    RegistryEntry* result = CAST_REGENTRY( RegistryEntry*, i_find( key->registry() ) );
+    RegistryEntry* result = i_find( key->registry() );
     if ( result ) return result;
     // Go levels down
-    for ( const auto& i : m_store ) {
-      try {
-        const RegistryEntry* entry = CAST_REGENTRY( RegistryEntry*, i );
-        result                     = entry->i_find( key );
+    try {
+      for ( const auto& i : m_store ) {
+        result = i->i_find( key );
         if ( result ) return result;
-      } catch ( ... ) {
       }
+    } catch ( ... ) {
     }
   }
   return nullptr;
@@ -296,16 +290,15 @@ DataSvcHelpers::RegistryEntry* DataSvcHelpers::RegistryEntry::i_find( const Data
 // Traverse registry tree
 StatusCode DataSvcHelpers::RegistryEntry::traverseTree( IDataStoreAgent* pAgent, int level )
 {
-  bool go_down = pAgent->analyse( this, level );
+  bool       go_down = pAgent->analyse( this, level );
   StatusCode status;
   if ( go_down ) {
-    for ( auto& i : m_store ) {
-      try {
-        RegistryEntry* entry = CAST_REGENTRY( RegistryEntry*, i );
-        entry->traverseTree( pAgent, level + 1 ).ignore();
-      } catch ( ... ) {
-        status = StatusCode::FAILURE;
+    try {
+      for ( auto& i : m_store ) {
+        i->traverseTree( pAgent, level + 1 ).ignore();
       }
+    } catch ( ... ) {
+      status = StatusCode::FAILURE;
     }
   }
   return status;
diff --git a/GaudiKernel/src/Lib/TsDataSvc.cpp b/GaudiKernel/src/Lib/TsDataSvc.cpp
index 161347c85..c5621177c 100644
--- a/GaudiKernel/src/Lib/TsDataSvc.cpp
+++ b/GaudiKernel/src/Lib/TsDataSvc.cpp
@@ -67,19 +67,12 @@ namespace
   std::string to_string( boost::string_ref sr ) { return {sr.data(), sr.size()}; }
 }
 
-// If you absolutely need optimization: switch off dynamic_cast.
-// This improves access to the data store roughly by 10 %
-// for balanced trees.
-//
-// M.Frank
-#define CAST_REGENTRY( x, y ) dynamic_cast<x>( y )
-//#define CAST_REGENTRY(x,y) (x)(y)
 typedef DataSvcHelpers::RegistryEntry RegEntry;
 
 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
 
-#define DEBMSG ON_DEBUG debug()
+#define DEBMSG ON_DEBUG   debug()
 #define VERMSG ON_VERBOSE verbose()
 
 /** IDataManagerSvc: Remove all data objects below the sub tree
@@ -88,9 +81,9 @@ typedef DataSvcHelpers::RegistryEntry RegEntry;
 StatusCode TsDataSvc::clearSubTree( boost::string_ref sub_tree_path )
 {
   DataObject* pObject = nullptr;
-  StatusCode status   = findObject( sub_tree_path, pObject );
+  StatusCode  status  = findObject( sub_tree_path, pObject );
   if ( !status.isSuccess() ) return status;
-  RegEntry* node_entry = CAST_REGENTRY( RegEntry*, pObject->registry() );
+  RegEntry* node_entry = pObject->registry();
   if ( !node_entry ) return Status::INVALID_OBJECT;
   RegEntry* parent = node_entry->parentEntry();
   if ( !parent ) return Status::INVALID_PARENT;
@@ -104,7 +97,7 @@ StatusCode TsDataSvc::clearSubTree( boost::string_ref sub_tree_path )
 StatusCode TsDataSvc::clearSubTree( DataObject* pObject )
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  RegEntry* entry = CAST_REGENTRY( RegEntry*, pObject->registry() );
+  RegEntry* entry = pObject->registry();
   if ( !entry ) return Status::INVALID_OBJECT;
   RegEntry* parent = entry->parentEntry();
   if ( !parent ) return Status::INVALID_PARENT;
@@ -116,8 +109,7 @@ StatusCode TsDataSvc::clearSubTree( DataObject* pObject )
 StatusCode TsDataSvc::clearStore()
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  m_root->release();
-  m_root = nullptr;
+  m_root.reset();
   return StatusCode::SUCCESS;
 }
 
@@ -127,8 +119,8 @@ StatusCode TsDataSvc::clearStore()
 StatusCode TsDataSvc::traverseSubTree( boost::string_ref sub_tree_path, IDataStoreAgent* pAgent )
 {
   STD_LOCK_GUARD_MACRO
-  DataObject* pO    = nullptr;
-  StatusCode status = findObject( sub_tree_path, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = findObject( sub_tree_path, pO );
   return status.isSuccess() ? traverseSubTree( pO, pAgent ) : status;
 }
 
@@ -137,7 +129,7 @@ StatusCode TsDataSvc::traverseSubTree( DataObject* pObject, IDataStoreAgent* pAg
 {
   STD_LOCK_GUARD_MACRO
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  RegEntry* entry = CAST_REGENTRY( RegEntry*, pObject->registry() );
+  RegEntry* entry = pObject->registry();
   if ( !entry ) return Status::INVALID_OBJECT;
   return entry->traverseTree( pAgent );
 }
@@ -168,7 +160,8 @@ StatusCode TsDataSvc::setRoot( std::string root_path, DataObject* pRootObj )
 StatusCode TsDataSvc::i_setRoot( std::string root_path, DataObject* pRootObj )
 {
   if ( pRootObj ) {
-    m_root = new RegEntry( std::move( root_path ) );
+    m_root.release(); // FIXME: inserted to keep previous behaviour...
+    m_root = std::make_unique<RegEntry>( std::move( root_path ) );
     m_root->makeHard( pRootObj );
     m_root->setDataSvc( this );
     // No done with GaudiHive. preLoad().ignore();
@@ -194,7 +187,8 @@ StatusCode TsDataSvc::setRoot( std::string root_path, IOpaqueAddress* pRootAddr
 StatusCode TsDataSvc::i_setRoot( std::string root_path, IOpaqueAddress* pRootAddr )
 {
   if ( pRootAddr ) {
-    m_root = new RegEntry( std::move( root_path ) );
+    m_root.release(); // FIXME: inserted to keep previous behaviour...
+    m_root = std::make_unique<RegEntry>( std::move( root_path ) );
     m_root->makeHard( pRootAddr );
     m_root->setDataSvc( this );
     // Not done with GaudiHive. preLoad().ignore();
@@ -205,38 +199,33 @@ StatusCode TsDataSvc::i_setRoot( std::string root_path, IOpaqueAddress* pRootAdd
 /// IDataManagerSvc: Pass a default data loader to the service.
 StatusCode TsDataSvc::setDataLoader( IConversionSvc* pDataLoader, IDataProviderSvc* dpsvc )
 {
-  if ( pDataLoader ) pDataLoader->addRef();
-  if ( m_dataLoader ) m_dataLoader->release();
-  if ( pDataLoader ) {
-    pDataLoader->setDataProvider( dpsvc == nullptr ? this : dpsvc ).ignore();
-  }
   m_dataLoader = pDataLoader;
+  if ( m_dataLoader ) m_dataLoader->setDataProvider( dpsvc ? dpsvc : this ).ignore();
   return StatusCode::SUCCESS;
 }
 
 /// IDataManagerSvc: Explore the object store: retrieve the object's parent
 StatusCode TsDataSvc::objectParent( const DataObject* pObject, IRegistry*& refpParent )
 {
-  STD_LOCK_GUARD_MACRO
   if ( !pObject ) return Status::INVALID_OBJECT;
+  STD_LOCK_GUARD_MACRO
   return objectParent( pObject->registry(), refpParent );
 }
 /// IDataManagerSvc: Explore the object store: retrieve the object's parent
 StatusCode TsDataSvc::objectParent( const IRegistry* pRegistry, IRegistry*& refpParent )
 {
+  if ( !pRegistry ) return Status::INVALID_OBJECT;
   STD_LOCK_GUARD_MACRO
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  const RegEntry* node_entry = CAST_REGENTRY( const RegEntry*, pRegistry );
-  if ( !node_entry ) return Status::INVALID_OBJECT;
-  refpParent = node_entry->parent();
+  refpParent = pRegistry->parent();
   return StatusCode::SUCCESS;
 }
 
 /// IDataManagerSvc: Explore an object identified by its pointer.
 StatusCode TsDataSvc::objectLeaves( const DataObject* pObject, std::vector<IRegistry*>& leaves )
 {
-  STD_LOCK_GUARD_MACRO
   if ( !pObject ) return Status::INVALID_OBJECT;
+  STD_LOCK_GUARD_MACRO
   return objectLeaves( pObject->registry(), leaves );
 }
 
@@ -245,12 +234,13 @@ StatusCode TsDataSvc::objectLeaves( const DataObject* pObject, std::vector<IRegi
  */
 StatusCode TsDataSvc::objectLeaves( const IRegistry* pRegistry, std::vector<IRegistry*>& leaves )
 {
+  if ( !pRegistry ) return Status::INVALID_OBJECT;
   STD_LOCK_GUARD_MACRO
   if ( !checkRoot() ) return Status::INVALID_ROOT;
-  const RegEntry* node_entry = CAST_REGENTRY( const RegEntry*, pRegistry );
-  if ( !node_entry ) return Status::INVALID_OBJECT;
-  leaves.insert( leaves.end(), node_entry->leaves().begin(), node_entry->leaves().end() );
-  // leaves = node_entry->leaves();
+  const auto& l = pRegistry->leaves();
+  leaves.clear();
+  leaves.reserve( l.size() );
+  std::transform( begin( l ), end( l ), std::back_inserter( leaves ), []( const auto& i ) { return i.get(); } );
   return StatusCode::SUCCESS;
 }
 
@@ -259,7 +249,7 @@ StatusCode TsDataSvc::registerAddress( boost::string_ref fullPath, IOpaqueAddres
 {
   if ( fullPath.empty() ) return Status::INVALID_OBJ_PATH;
   if ( fullPath.front() != SEPARATOR ) {
-    return registerAddress( m_root, fullPath, pAddress );
+    return registerAddress( m_root.get(), fullPath, pAddress );
   }
   IRegistry* pRegistry = nullptr;
   return registerAddress( pRegistry, fullPath, pAddress );
@@ -279,36 +269,35 @@ StatusCode TsDataSvc::registerAddress( IRegistry* parentObj, boost::string_ref o
   if ( objPath.empty() ) return Status::INVALID_OBJ_PATH;
   if ( !parentObj ) {
     if ( objPath.front() != SEPARATOR ) {
-      return registerAddress( m_root, objPath, pAddress );
+      return registerAddress( m_root.get(), objPath, pAddress );
     }
     auto sep = find( objPath, SEPARATOR, 1 );
     if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) != m_rootName.value() ) {
       return Status::INVALID_PARENT;
     }
-    return registerAddress( m_root, objPath.substr( sep ), pAddress );
+    return registerAddress( m_root.get(), objPath.substr( sep ), pAddress );
   }
   if ( objPath.front() != SEPARATOR ) {
     return registerAddress( parentObj, SEPARATOR + objPath, pAddress );
   }
-  RegEntry* par_entry = CAST_REGENTRY( RegEntry*, parentObj );
-  if ( !par_entry ) return Status::INVALID_PARENT;
+  if ( !parentObj ) return Status::INVALID_PARENT;
   auto sep = objPath.rfind( SEPARATOR );
   if ( sep > 0 && sep != boost::string_ref::npos ) {
-    auto p_path       = objPath.substr( 0, sep );
-    auto o_path       = objPath.substr( sep );
-    RegEntry* p_entry = par_entry->findLeaf( p_path );
+    auto      p_path  = objPath.substr( 0, sep );
+    auto      o_path  = objPath.substr( sep );
+    RegEntry* p_entry = parentObj->findLeaf( p_path );
     // Create default object leafs if the
     // intermediate nodes are not present
     if ( !p_entry && m_forceLeaves ) {
       DataObject* pLeaf = createDefaultObject();
-      StatusCode sc     = registerObject( par_entry->identifier(), p_path, pLeaf );
+      StatusCode  sc    = registerObject( parentObj->identifier(), p_path, pLeaf );
       if ( !sc.isSuccess() ) delete pLeaf;
-      p_entry = par_entry->findLeaf( p_path );
+      p_entry = parentObj->findLeaf( p_path );
     }
     if ( !p_entry ) return Status::INVALID_PARENT;
     return registerAddress( p_entry, o_path, pAddress );
   }
-  StatusCode status = par_entry->add( to_string( objPath ), pAddress );
+  StatusCode status = parentObj->add( to_string( objPath ), pAddress );
   return status.isSuccess() ? status : Status::DOUBL_OBJ_PATH;
 }
 
@@ -318,7 +307,7 @@ StatusCode TsDataSvc::unregisterAddress( boost::string_ref fullPath )
   if ( fullPath.empty() ) return Status::INVALID_OBJ_PATH;
   IRegistry* pRegistry = nullptr;
   if ( fullPath.front() != SEPARATOR ) {
-    return unregisterAddress( m_root, fullPath );
+    return unregisterAddress( m_root.get(), fullPath );
   }
   return unregisterAddress( pRegistry, fullPath );
 }
@@ -338,26 +327,25 @@ StatusCode TsDataSvc::unregisterAddress( IRegistry* pParent, boost::string_ref o
   if ( objPath.empty() ) return Status::INVALID_OBJ_PATH;
   if ( !pParent ) {
     if ( objPath.front() != SEPARATOR ) {
-      return unregisterAddress( m_root, objPath );
+      return unregisterAddress( m_root.get(), objPath );
     }
     auto sep = find( objPath, SEPARATOR, 1 );
     if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) != m_rootName.value() ) {
       return Status::INVALID_PARENT;
     }
-    return unregisterAddress( m_root, objPath.substr( sep ) );
+    return unregisterAddress( m_root.get(), objPath.substr( sep ) );
   }
   if ( objPath.front() != SEPARATOR ) {
     return unregisterAddress( pParent, SEPARATOR + objPath );
   }
-  RegEntry* node_entry = CAST_REGENTRY( RegEntry*, pParent );
-  if ( node_entry ) {
-    RegEntry* leaf_entry = node_entry->findLeaf( objPath );
+  if ( pParent ) {
+    RegEntry* leaf_entry = pParent->findLeaf( objPath );
     if ( leaf_entry ) {
       auto sep = objPath.rfind( SEPARATOR );
       if ( sep > 0 && sep != boost::string_ref::npos ) {
         return unregisterAddress( leaf_entry->parent(), objPath.substr( sep ) );
       }
-      StatusCode status = node_entry->remove( objPath );
+      StatusCode status = pParent->remove( objPath );
       if ( status.isSuccess() ) return status;
     }
   }
@@ -373,8 +361,8 @@ StatusCode TsDataSvc::registerObject( boost::string_ref fullPath, DataObject* pO
 /// Register object with the data store.
 StatusCode TsDataSvc::registerObject( boost::string_ref parentPath, boost::string_ref objPath, DataObject* pObject )
 {
-  DataObject* pO    = nullptr;
-  StatusCode status = retrieveObject( parentPath, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = retrieveObject( parentPath, pO );
   if ( !status.isSuccess() && m_forceLeaves ) {
     pO     = createDefaultObject();
     status = registerObject( parentPath, pO );
@@ -411,26 +399,26 @@ StatusCode TsDataSvc::registerObject( DataObject* parentObj, boost::string_ref o
     }
     return Status::INVALID_OBJ_PATH;
   }
-  RegEntry* node_entry = CAST_REGENTRY( RegEntry*, parentObj->registry() );
+  RegEntry* node_entry = parentObj->registry();
   if ( node_entry ) {
     StatusCode status = Status::INVALID_PARENT;
-    auto sep          = find( objPath, SEPARATOR, 1 );
+    auto       sep    = find( objPath, SEPARATOR, 1 );
     if ( sep != boost::string_ref::npos ) {
-      auto p_path         = objPath.substr( 0, sep );
-      auto o_path         = objPath.substr( sep );
+      auto      p_path    = objPath.substr( 0, sep );
+      auto      o_path    = objPath.substr( sep );
       RegEntry* par_entry = node_entry->findLeaf( p_path );
       // Create default object leafs if the
       // intermediate nodes are not present
       if ( !par_entry && m_forceLeaves ) {
         DataObject* pLeaf = createDefaultObject();
-        StatusCode sc     = registerObject( parentObj, p_path, pLeaf );
+        StatusCode  sc    = registerObject( parentObj, p_path, pLeaf );
         if ( !sc.isSuccess() ) delete pLeaf;
         par_entry = node_entry->findLeaf( p_path );
       } else if ( par_entry && !par_entry->object() ) {
         status = retrieveEntry( node_entry, p_path, par_entry );
         if ( !status.isSuccess() && !par_entry->address() && m_forceLeaves ) {
           DataObject* pLeaf = createDefaultObject();
-          StatusCode sc     = registerObject( parentObj, p_path, pLeaf );
+          StatusCode  sc    = registerObject( parentObj, p_path, pLeaf );
           if ( !sc.isSuccess() ) delete pLeaf;
           par_entry = node_entry->findLeaf( p_path );
         }
@@ -470,9 +458,9 @@ StatusCode TsDataSvc::registerObject( DataObject* parentObj, boost::string_ref o
 StatusCode TsDataSvc::unregisterObject( boost::string_ref fullPath )
 {
   DataObject* pObject = nullptr;
-  StatusCode status   = findObject( fullPath, pObject );
+  StatusCode  status  = findObject( fullPath, pObject );
   if ( status.isFailure() ) return status;
-  RegEntry* pEntry = CAST_REGENTRY( RegEntry*, pObject->registry() );
+  RegEntry* pEntry = pObject->registry();
   if ( !pEntry ) return Status::INVALID_ROOT;
   if ( !pEntry->isEmpty() ) return Status::DIR_NOT_EMPTY;
   RegEntry* pParent = pEntry->parentEntry();
@@ -485,8 +473,8 @@ StatusCode TsDataSvc::unregisterObject( boost::string_ref fullPath )
 /// Unregister object from the data store.
 StatusCode TsDataSvc::unregisterObject( boost::string_ref parentPath, boost::string_ref objPath )
 {
-  DataObject* pO    = nullptr;
-  StatusCode status = findObject( parentPath, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = findObject( parentPath, pO );
   return status.isSuccess() ? unregisterObject( pO, objPath ) : status;
 }
 
@@ -515,7 +503,7 @@ StatusCode TsDataSvc::unregisterObject( DataObject* pParentObj, boost::string_re
 {
   if ( !checkRoot() ) return Status::INVALID_ROOT;
   try {
-    RegEntry* parent = CAST_REGENTRY( RegEntry*, pParentObj->registry() );
+    RegEntry* parent = pParentObj->registry();
     if ( parent ) {
       RegEntry* entry = parent->findLeaf( objectPath );
       if ( !entry ) return Status::INVALID_OBJECT;
@@ -580,7 +568,7 @@ StatusCode TsDataSvc::loadObject( IRegistry* pRegistry )
 StatusCode TsDataSvc::loadObject( IConversionSvc* pLoader, IRegistry* pRegistry )
 {
   STD_LOCK_GUARD_MACRO
-  StatusCode status   = Status::INVALID_OBJ_ADDR;
+  StatusCode  status  = Status::INVALID_OBJ_ADDR;
   DataObject* pObject = nullptr;
   if ( !pLoader ) { // Precondition: Data loader must be present
     if ( handleDataFault( pRegistry ) )
@@ -603,8 +591,8 @@ StatusCode TsDataSvc::loadObject( IConversionSvc* pLoader, IRegistry* pRegistry
     m_incidentSvc->fireIncident( incident );
   }
   if ( !m_inhibitPathes.empty() ) {
-    const auto& ident = pRegistry->identifier();
-    auto inhibit      = std::find( m_inhibitPathes.begin(), m_inhibitPathes.end(), ident );
+    const auto& ident   = pRegistry->identifier();
+    auto        inhibit = std::find( m_inhibitPathes.begin(), m_inhibitPathes.end(), ident );
     if ( inhibit != m_inhibitPathes.end() ) return Status::NO_ACCESS;
   }
   IOpaqueAddress* pAddress = pRegistry->address();
@@ -617,8 +605,7 @@ StatusCode TsDataSvc::loadObject( IConversionSvc* pLoader, IRegistry* pRegistry
 
       VERMSG << "Object " << pRegistry->identifier() << " created" << endmsg;
 
-      RegEntry* pEntry = CAST_REGENTRY( RegEntry*, pRegistry );
-      pEntry->setObject( pObject );
+      pRegistry->setObject( pObject );
 
       VERMSG << "Filling object " << pRegistry->identifier() << endmsg;
       status = pLoader->fillObjRefs( pAddress, pObject );
@@ -650,21 +637,21 @@ StatusCode TsDataSvc::loadObject( IConversionSvc* pLoader, IRegistry* pRegistry
 StatusCode TsDataSvc::retrieveEntry( RegEntry* parentObj, boost::string_ref path, RegEntry*& pEntry )
 {
   STD_LOCK_GUARD_MACRO
-  auto sep          = find( path, SEPARATOR, 1 );
+  auto       sep    = find( path, SEPARATOR, 1 );
   StatusCode status = StatusCode( Status::INVALID_ROOT, true );
   pEntry            = nullptr;
   // A.Valassi 16.08.2001 avoid core dump if store is empty
   if ( checkRoot() ) {
     if ( !parentObj ) {
-      if ( path.empty() || path == m_rootName ) return retrieveEntry( m_root, "", pEntry );
-      if ( path.front() != SEPARATOR ) return retrieveEntry( m_root, path, pEntry );
+      if ( path.empty() || path == m_rootName ) return retrieveEntry( m_root.get(), "", pEntry );
+      if ( path.front() != SEPARATOR ) return retrieveEntry( m_root.get(), path, pEntry );
       if ( sep == boost::string_ref::npos ) return Status::INVALID_OBJ_PATH;
       if ( !m_root->object() ) {
         RegEntry* r = nullptr;
-        status      = retrieveEntry( m_root, "", r );
+        status      = retrieveEntry( m_root.get(), "", r );
         if ( !status.isSuccess() ) return status;
       }
-      return retrieveEntry( m_root, path.substr( sep ), pEntry );
+      return retrieveEntry( m_root.get(), path.substr( sep ), pEntry );
     }
     if ( sep != boost::string_ref::npos ) { // the string contains a separator (after pos 0)
       auto p_path = path.substr( 0, sep );
@@ -688,7 +675,7 @@ StatusCode TsDataSvc::retrieveEntry( RegEntry* parentObj, boost::string_ref path
           if ( !status.isSuccess() ) return status;
         }
         if ( root_entry->isSoft() ) {
-          root_entry = CAST_REGENTRY( RegEntry*, pO->registry() );
+          root_entry = pO->registry();
         }
         return retrieveEntry( root_entry, o_path, pEntry );
       }
@@ -731,10 +718,10 @@ StatusCode TsDataSvc::retrieveEntry( RegEntry* parentObj, boost::string_ref path
 /// Retrieve object identified by its directory from the data store.
 StatusCode TsDataSvc::retrieveObject( IRegistry* pRegistry, boost::string_ref path, DataObject*& pObject )
 {
-  STD_LOCK_GUARD_MACRO
   pObject          = nullptr;
-  RegEntry *result = nullptr, *parent = CAST_REGENTRY( RegEntry *, pRegistry );
-  StatusCode status                 = retrieveEntry( parent, path, result );
+  RegEntry* result = nullptr;
+  STD_LOCK_GUARD_MACRO
+  StatusCode status                 = retrieveEntry( pRegistry, path, result );
   if ( status.isSuccess() ) pObject = result->object();
   return status;
 }
@@ -750,7 +737,7 @@ StatusCode TsDataSvc::retrieveObject( boost::string_ref fullPath, DataObject*& p
 StatusCode TsDataSvc::retrieveObject( boost::string_ref parentPath, boost::string_ref objectPath, DataObject*& pObject )
 {
   DataObject* parent = nullptr;
-  StatusCode status  = retrieveObject( parentPath, parent );
+  StatusCode  status = retrieveObject( parentPath, parent );
   return status.isSuccess() ? retrieveObject( parent, objectPath, pObject ) : status;
 }
 
@@ -776,12 +763,11 @@ StatusCode TsDataSvc::retrieveObject( DataObject* parentObj, int item, DataObjec
 /// Retrieve object identified by its directory from the data store.
 StatusCode TsDataSvc::findObject( IRegistry* pRegistry, boost::string_ref path, DataObject*& pObject )
 {
+  pObject = nullptr;
   STD_LOCK_GUARD_MACRO
-  pObject              = nullptr;
-  IRegistry* pReg      = ( pRegistry ? pRegistry : m_root );
-  RegEntry* root_entry = CAST_REGENTRY( RegEntry*, pReg );
-  if ( root_entry ) {
-    if ( !path.empty() ) pReg = root_entry->find( path );
+  IRegistry* pReg = ( pRegistry ? pRegistry : m_root.get() );
+  if ( pReg ) {
+    if ( !path.empty() ) pReg = pReg->find( path );
     if ( !pReg ) return Status::INVALID_OBJ_PATH;
     pObject = pReg->object();
   }
@@ -808,7 +794,7 @@ StatusCode TsDataSvc::findObject( boost::string_ref path, DataObject*& pObject )
 StatusCode TsDataSvc::findObject( boost::string_ref parentPath, boost::string_ref objectPath, DataObject*& pObject )
 {
   DataObject* parent = nullptr;
-  StatusCode status  = findObject( parentPath, parent );
+  StatusCode  status = findObject( parentPath, parent );
   return status.isSuccess() ? findObject( parent, objectPath, pObject ) : status;
 }
 
@@ -833,8 +819,8 @@ StatusCode TsDataSvc::findObject( DataObject* parentObj, boost::string_ref path,
 /// Update object.
 StatusCode TsDataSvc::updateObject( boost::string_ref updatePath )
 {
-  DataObject* pO    = nullptr;
-  StatusCode status = findObject( updatePath, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = findObject( updatePath, pO );
   return status.isSuccess() ? updateObject( pO ) : retrieveObject( updatePath, pO );
 }
 
@@ -872,8 +858,8 @@ StatusCode TsDataSvc::updateObject( DataObject* toUpdate )
     return Status::NO_DATA_LOADER; // Data loader must be present
   }
   if ( !m_inhibitPathes.empty() ) {
-    auto& ident  = pRegistry->identifier();
-    auto inhibit = std::find( m_inhibitPathes.begin(), m_inhibitPathes.end(), ident );
+    auto& ident   = pRegistry->identifier();
+    auto  inhibit = std::find( m_inhibitPathes.begin(), m_inhibitPathes.end(), ident );
     if ( inhibit != m_inhibitPathes.end() ) return Status::NO_ACCESS;
   }
   try {
@@ -897,7 +883,7 @@ StatusCode TsDataSvc::updateObject( DataObject* toUpdate )
 StatusCode TsDataSvc::updateObject( boost::string_ref parentPath, boost::string_ref updatePath )
 {
   DataObject* pParent = nullptr;
-  StatusCode status   = findObject( parentPath, pParent );
+  StatusCode  status  = findObject( parentPath, pParent );
   return status.isSuccess() ? updateObject( pParent, updatePath ) : status;
 }
 
@@ -905,7 +891,7 @@ StatusCode TsDataSvc::updateObject( boost::string_ref parentPath, boost::string_
 StatusCode TsDataSvc::updateObject( DataObject* parent, boost::string_ref updatePath )
 {
   DataObject* pObject = nullptr;
-  StatusCode status   = findObject( parent, updatePath, pObject );
+  StatusCode  status  = findObject( parent, updatePath, pObject );
   return status.isSuccess() ? updateObject( pObject ) : status;
 }
 
@@ -915,19 +901,18 @@ StatusCode TsDataSvc::linkObject( IRegistry* from, boost::string_ref objPath, Da
   STD_LOCK_GUARD_MACRO
   if ( !checkRoot() ) return Status::INVALID_ROOT;
   try {
-    RegEntry* from_entry = CAST_REGENTRY( RegEntry*, from );
-    if ( from_entry ) {
+    if ( from ) {
       // First check if both objects are already registered to the store
       RegEntry* to_entry = m_root->findLeaf( to );
       if ( !to_entry ) return Status::INVALID_OBJECT;
       auto sep = objPath.rfind( SEPARATOR );
       if ( sep > 0 && sep != boost::string_ref::npos ) { // in case the objPath is a sub-directory itself
         DataObject* pO = nullptr;
-        StatusCode sc  = retrieveObject( from, objPath.substr( 0, sep ), pO );
+        StatusCode  sc = retrieveObject( from, objPath.substr( 0, sep ), pO );
         return sc.isSuccess() ? linkObject( pO->registry(), objPath.substr( sep ), to ) : sc;
       }
       // Now register the soft link
-      StatusCode status = from_entry->add( to_string( objPath ), to, true );
+      StatusCode status = from->add( to_string( objPath ), to, true );
       return status.isSuccess() ? Status::IDataProviderSvc_NO_ERROR : Status::DOUBL_OBJ_PATH;
     }
   } catch ( ... ) {
@@ -949,8 +934,8 @@ StatusCode TsDataSvc::linkObject( boost::string_ref fullPath, DataObject* to )
 StatusCode TsDataSvc::linkObject( boost::string_ref from, boost::string_ref objPath, DataObject* to )
 {
   STD_LOCK_GUARD_MACRO
-  DataObject* pO    = nullptr;
-  StatusCode status = retrieveObject( from, pO );
+  DataObject* pO     = nullptr;
+  StatusCode  status = retrieveObject( from, pO );
   return status.isSuccess() ? linkObject( pO->registry(), objPath, to ) : status;
 }
 
@@ -971,15 +956,14 @@ StatusCode TsDataSvc::unlinkObject( IRegistry* from, boost::string_ref objPath )
   STD_LOCK_GUARD_MACRO
   if ( !checkRoot() ) return Status::INVALID_ROOT;
   try {
-    RegEntry* from_entry = CAST_REGENTRY( RegEntry*, from );
-    if ( from_entry ) {
+    if ( from ) {
       auto sep = objPath.rfind( SEPARATOR );
       if ( sep > 0 && sep != boost::string_ref::npos ) { // in case the objPath is a sub-directory itself
         DataObject* pO = nullptr;
-        StatusCode sc  = findObject( from, objPath.substr( 0, sep ), pO );
+        StatusCode  sc = findObject( from, objPath.substr( 0, sep ), pO );
         return sc.isSuccess() ? unlinkObject( pO->registry(), objPath.substr( sep ) ) : sc;
       }
-      StatusCode status = from_entry->remove( objPath );
+      StatusCode status = from->remove( objPath );
       return status.isSuccess() ? status : Status::INVALID_OBJ_PATH;
     }
   } catch ( ... ) {
@@ -1002,7 +986,7 @@ StatusCode TsDataSvc::unlinkObject( boost::string_ref fullPath )
 StatusCode TsDataSvc::unlinkObject( boost::string_ref from, boost::string_ref objPath )
 {
   DataObject* pObject = nullptr;
-  StatusCode status   = findObject( from, pObject );
+  StatusCode  status  = findObject( from, pObject );
   return status.isSuccess() ? unlinkObject( pObject->registry(), objPath ) : status;
 }
 
@@ -1053,11 +1037,11 @@ StatusCode TsDataSvc::preLoad( int depth, int load_depth, DataObject* pObject )
 {
   // unused:  StatusCode sc = StatusCode::FAILURE;
   if ( pObject && depth++ < load_depth ) {
-    RegEntry* dir = CAST_REGENTRY( RegEntry*, pObject->registry() );
+    RegEntry* dir = pObject->registry();
     if ( dir ) {
       for ( const auto& i : *dir ) {
-        DataObject* pObj  = nullptr;
-        StatusCode status = retrieveObject( pObject, i->name(), pObj );
+        DataObject* pObj   = nullptr;
+        StatusCode  status = retrieveObject( pObject, i->name(), pObj );
         if ( status.isSuccess() && depth < load_depth ) {
           preLoad( depth, load_depth, pObj ).ignore();
         }
@@ -1072,8 +1056,8 @@ StatusCode TsDataSvc::preLoad()
 {
   DataObject* pObj = nullptr;
   for ( const auto& i : m_preLoads ) {
-    StatusCode sc  = retrieveObject( i.path(), pObj );
-    int load_depth = i.depth();
+    StatusCode sc         = retrieveObject( i.path(), pObj );
+    int        load_depth = i.depth();
     if ( sc.isSuccess() && load_depth > 1 ) {
       preLoad( 1, load_depth, pObj ).ignore();
     }
@@ -1086,9 +1070,9 @@ StatusCode TsDataSvc::initialize()
 {
   // Nothing to do: just call base class initialisation
   StatusCode sc = Service::initialize();
-  if ( !sc.isSuccess() ) return sc;
-  sc = service( "IncidentSvc", m_incidentSvc, true );
-  if ( UNLIKELY( !sc.isSuccess() ) ) {
+  if ( UNLIKELY( !sc.isSuccess() ) ) return sc;
+  m_incidentSvc = service( "IncidentSvc", true );
+  if ( UNLIKELY( !m_incidentSvc ) ) {
     error() << "Failed to access incident service." << endmsg;
   }
   return sc;
@@ -1097,24 +1081,20 @@ StatusCode TsDataSvc::initialize()
 /// Service reinitialization
 StatusCode TsDataSvc::reinitialize()
 {
-  StatusCode sc;
   // the finalize part is copied here
   setDataLoader( nullptr ).ignore();
   resetPreLoad().ignore();
   clearStore().ignore();
-  if ( m_incidentSvc ) {
-    m_incidentSvc->release();
-    m_incidentSvc = nullptr;
-  }
+  m_incidentSvc.reset();
   // re-initialize the base class
-  sc = Service::reinitialize();
+  StatusCode sc = Service::reinitialize();
   if ( UNLIKELY( !sc.isSuccess() ) ) {
     error() << "Unable to reinitialize base class" << endmsg;
     return sc;
   }
   // the initialize part is copied here
-  sc = service( "IncidentSvc", m_incidentSvc, true );
-  if ( UNLIKELY( !sc.isSuccess() ) ) {
+  m_incidentSvc = service( "IncidentSvc", true );
+  if ( UNLIKELY( !m_incidentSvc ) ) {
     error() << "Failed to access incident service." << endmsg;
     return sc;
   }
@@ -1129,10 +1109,7 @@ StatusCode TsDataSvc::finalize()
   setDataLoader( nullptr ).ignore();
   resetPreLoad().ignore();
   clearStore().ignore();
-  if ( m_incidentSvc ) {
-    m_incidentSvc->release();
-    m_incidentSvc = nullptr;
-  }
+  m_incidentSvc.reset();
   return Service::finalize();
 }
 
diff --git a/GaudiPython/python/GaudiPython/Bindings.py b/GaudiPython/python/GaudiPython/Bindings.py
index 83c2be7d0..a0312ffdb 100644
--- a/GaudiPython/python/GaudiPython/Bindings.py
+++ b/GaudiPython/python/GaudiPython/Bindings.py
@@ -582,11 +582,11 @@ class iDataSvc(iService):
     def leaves(self, node=None):
         if not node:
             node = self.retrieveObject('')
-        ll = gbl.std.vector('IRegistry*')()
         if type(node) is str:
             obj = self.retrieveObject(node)
         else:
             obj = node
+        ll = gbl.std.vector('DataSvcHelpers::RegistryEntry *')()
         if self._idm.objectLeaves(node, ll).isSuccess():
             return ll
 
diff --git a/GaudiUtils/GaudiUtils/IFileCatalog.h b/GaudiUtils/GaudiUtils/IFileCatalog.h
index 3179c65c7..e39daa7be 100644
--- a/GaudiUtils/GaudiUtils/IFileCatalog.h
+++ b/GaudiUtils/GaudiUtils/IFileCatalog.h
@@ -37,8 +37,8 @@ namespace Gaudi
 
     /// Public type definitions
     typedef std::pair<std::string, std::string> NamedItem;
-    typedef std::vector<NamedItem> Attributes;
-    typedef std::vector<NamedItem> Files;
+    typedef std::vector<NamedItem>   Attributes;
+    typedef std::vector<NamedItem>   Files;
     typedef std::vector<std::string> Strings;
 
     /** Catalog interface                                               */
diff --git a/GaudiUtils/src/component/MultiFileCatalog.h b/GaudiUtils/src/component/MultiFileCatalog.h
index 33f6c2e4b..868d939c6 100644
--- a/GaudiUtils/src/component/MultiFileCatalog.h
+++ b/GaudiUtils/src/component/MultiFileCatalog.h
@@ -25,9 +25,9 @@ namespace Gaudi
     typedef Service::Factory Factory;
 
   protected:
-    typedef const std::string& CSTR;
+    typedef const std::string&         CSTR;
     typedef std::vector<IFileCatalog*> Catalogs;
-    typedef std::vector<std::string> CatalogNames;
+    typedef std::vector<std::string>   CatalogNames;
 
     template <class A1, class F>
     std::string _find( A1& arg1, F pmf ) const
diff --git a/GaudiUtils/src/component/XMLFileCatalog.cpp b/GaudiUtils/src/component/XMLFileCatalog.cpp
index 3a817e735..5981131e2 100644
--- a/GaudiUtils/src/component/XMLFileCatalog.cpp
+++ b/GaudiUtils/src/component/XMLFileCatalog.cpp
@@ -41,7 +41,7 @@ namespace
   typedef const string& CSTR;
   inline string _toString( const XMLCh* toTranscode )
   {
-    char* buff = XMLString::transcode( toTranscode );
+    char*  buff = XMLString::transcode( toTranscode );
     string tmp( buff == 0 ? "" : buff );
     XMLString::release( &buff );
     return tmp;
@@ -91,7 +91,7 @@ namespace
     DOMElement* operator->() const { return m_node; }
     string attr( const XMLTag& tag ) const { return _toString( m_node->getAttribute( tag ) ); }
     string attr( CSTR tag ) const { return attr( XMLTag( tag ) ); }
-    string tag() const { return _toString( m_node->getTagName() ); }
+    string            tag() const { return _toString( m_node->getTagName() ); }
     void operator++()
     {
       while ( m_node ) {
@@ -119,8 +119,8 @@ namespace
   struct DTDRedirect : public EntityResolver {
     InputSource* resolveEntity( const XMLCh* const /* pubId */, const XMLCh* const /* sysId */ ) override
     {
-      static const char* dtdID = "redirectinmem.dtd";
-      static const char* dtd   = "\
+      static const char*  dtdID = "redirectinmem.dtd";
+      static const char*  dtd   = "\
         <!ELEMENT POOLFILECATALOG (META*,File*)>\
         <!ELEMENT META EMPTY>\
         <!ELEMENT File (physical,logical,metadata*)>\
@@ -139,7 +139,7 @@ namespace
         <!ATTLIST metadata att_name  CDATA #REQUIRED>\
         <!ATTLIST metadata att_value CDATA #REQUIRED>\
         ";
-      static const size_t len  = strlen( dtd );
+      static const size_t len   = strlen( dtd );
       return new MemBufInputSource( (const XMLByte*)dtd, len, dtdID, false );
     }
   };
@@ -154,7 +154,7 @@ namespace
          m.find( "for attribute 'name' is invalid Name or NMTOKEN value" ) != string::npos ||
          m.find( "for attribute 'ID' is invalid Name or NMTOKEN value" ) != string::npos )
       return;
-    string sys( _toString( e.getSystemId() ) );
+    string    sys( _toString( e.getSystemId() ) );
     MsgStream log( m_msg, "XMLCatalog" );
     log << MSG::ERROR << "Error at file \"" << sys << "\", line " << e.getLineNumber() << ", column "
         << e.getColumnNumber() << endmsg << "Message: " << m << endmsg;
@@ -162,8 +162,8 @@ namespace
   void ErrHandler::fatalError( const SAXParseException& e )
   {
     MsgStream log( m_msg, "XMLCatalog" );
-    string m( _toString( e.getMessage() ) );
-    string sys( _toString( e.getSystemId() ) );
+    string    m( _toString( e.getMessage() ) );
+    string    sys( _toString( e.getSystemId() ) );
     log << MSG::ERROR << "Fatal Error at file \"" << sys << "\", line " << e.getLineNumber() << ", column "
         << e.getColumnNumber() << endmsg << "Message: " << m << endmsg;
     throw runtime_error( "Standard pool exception : Fatal Error on the DOM Parser" );
@@ -220,7 +220,7 @@ void XMLFileCatalog::init()
       m_parser->parse( xmlFile.c_str() );
     } else {
       const std::string& s = EmptyCatalog;
-      MemBufInputSource src( (const XMLByte*)s.c_str(), s.length(), "MemCatalog" );
+      MemBufInputSource  src( (const XMLByte*)s.c_str(), s.length(), "MemCatalog" );
       m_parser->parse( src );
     }
     m_doc = m_parser->getDocument();
@@ -236,9 +236,9 @@ void XMLFileCatalog::init()
 string XMLFileCatalog::lookupFID( const std::string& fid ) const
 {
   std::string result;
-  DOMNode* e = element( fid, false );
-  e          = e ? e->getParentNode() : 0; // Mode up to <logical>
-  e          = e ? e->getParentNode() : 0; // Mode up to <File>
+  DOMNode*    e = element( fid, false );
+  e             = e ? e->getParentNode() : 0; // Mode up to <logical>
+  e             = e ? e->getParentNode() : 0; // Mode up to <File>
   if ( e ) {
     if ( e->getAttributes() ) { // Need to check this. The node may be no DOMElement
       char* nam         = XMLString::transcode( ( (DOMElement*)e )->getAttribute( Attr_ID ) );
@@ -292,7 +292,7 @@ DOMNode* XMLFileCatalog::child( DOMNode* par, CSTR tag, CSTR attr, CSTR val ) co
 void XMLFileCatalog::setMetaData( CSTR fid, CSTR attr, CSTR val ) const
 {
   if ( !readOnly() ) {
-    DOMNode* node    = element( fid );
+    DOMNode*    node = element( fid );
     DOMElement* mnod = (DOMElement*)child( node, MetaNode, Attr_metaName, attr );
     if ( !mnod ) {
       mnod = getDoc( true )->createElement( MetaNode );
@@ -315,7 +315,7 @@ string XMLFileCatalog::getMetaDataItem( CSTR fid, CSTR attr ) const
 void XMLFileCatalog::dropMetaData( CSTR fid, CSTR attr ) const
 {
   vector<DOMNode*> gbc;
-  DOMNode* fn = getDoc( true )->getElementById( XMLStr( fid ) );
+  DOMNode*         fn = getDoc( true )->getElementById( XMLStr( fid ) );
   for ( XMLCollection c{child( fn, MetaNode )}; c; ++c )
     if ( attr[0] == '*' || !c.attr( attr ).empty() ) gbc.push_back( c );
   for ( const auto& i : gbc ) fn->removeChild( i );
@@ -380,7 +380,7 @@ std::pair<DOMElement*, DOMElement*> XMLFileCatalog::i_registerFID( CSTR fid ) co
   }
 
   /// It creates a new node File with name = fid in the XML file catalog
-  DOMElement *file = (DOMElement *)element( fid, false ), *phyelem = 0, *logelem = 0;
+  DOMElement * file = (DOMElement *)element( fid, false ), *phyelem = 0, *logelem = 0;
   DOMDocument* doc = getDoc( true );
   if ( !file ) {
     DOMNode* fde = doc->getElementsByTagName( XMLStr( "*" ) )->item( 0 );
@@ -473,10 +473,10 @@ void XMLFileCatalog::commit()
 {
   try {
     if ( dirty() && !readOnly() ) {
-      string xmlfile = getfile( true );
-      XMLStr ii( "LS" );
+      string             xmlfile = getfile( true );
+      XMLStr             ii( "LS" );
       DOMImplementation* imp = DOMImplementationRegistry::getDOMImplementation( ii );
-      auto tar               = std::make_unique<LocalFileFormatTarget>( xmlfile.c_str() );
+      auto               tar = std::make_unique<LocalFileFormatTarget>( xmlfile.c_str() );
 #if _XERCES_VERSION <= 30000
       DOMWriter* wr = imp->createDOMWriter();
       wr->setFeature( XMLUni::fgDOMWRTFormatPrettyPrint, true );
@@ -517,7 +517,7 @@ string XMLFileCatalog::getfile( bool create )
   } else if ( protocol == "file" ) {
     m_rdOnly = false;
     struct stat buff;
-    int exist = ::stat( path.c_str(), &buff ) != -1;
+    int         exist = ::stat( path.c_str(), &buff ) != -1;
     if ( create && !exist ) {
       MsgStream log( m_msgSvc, "XMLCatalog" );
       log << MSG::INFO << "File '" << path << "' does not exist. New file created." << endmsg;
diff --git a/GaudiUtils/src/component/XMLFileCatalog.h b/GaudiUtils/src/component/XMLFileCatalog.h
index 1505562ab..345d2f9cd 100644
--- a/GaudiUtils/src/component/XMLFileCatalog.h
+++ b/GaudiUtils/src/component/XMLFileCatalog.h
@@ -99,13 +99,13 @@ namespace Gaudi
     xercesc::DOMNode* element( CSTR fid, bool print_err = true ) const;
     xercesc::DOMNode* child( xercesc::DOMNode* par, CSTR tag, CSTR attr = "", CSTR val = "" ) const;
     std::pair<xercesc::DOMElement*, xercesc::DOMElement*> i_registerFID( CSTR fid ) const;
-    bool m_rdOnly               = false;
-    mutable bool m_update       = false;
-    xercesc::DOMDocument* m_doc = nullptr;
+    bool                                      m_rdOnly = false;
+    mutable bool                              m_update = false;
+    xercesc::DOMDocument*                     m_doc    = nullptr;
     std::unique_ptr<xercesc::XercesDOMParser> m_parser;
-    std::unique_ptr<xercesc::ErrorHandler> m_errHdlr;
-    std::string m_file;
-    IMessageSvc* m_msgSvc;
+    std::unique_ptr<xercesc::ErrorHandler>    m_errHdlr;
+    std::string                               m_file;
+    IMessageSvc*                              m_msgSvc;
   };
   /// Create file identifier using UUID mechanism
   std::string createGuidAsString();
diff --git a/RootCnv/RootCnv/RootDataConnection.h b/RootCnv/RootCnv/RootDataConnection.h
index fcfa99a24..28013ad7e 100644
--- a/RootCnv/RootCnv/RootDataConnection.h
+++ b/RootCnv/RootCnv/RootDataConnection.h
@@ -21,7 +21,7 @@ class TClass;
 class TBranch;
 
 class MsgStream;
-class IRegistry;
+#include "GaudiKernel/IRegistry.h"
 class DataObject;
 class IIncidentSvc;
 
@@ -195,28 +195,28 @@ namespace Gaudi
     class Tool
     {
     protected:
-      typedef RootDataConnection::StringVec StringVec;
-      typedef RootDataConnection::ParamMap ParamMap;
-      typedef RootDataConnection::Sections Sections;
-      typedef RootDataConnection::MergeSections MergeSections;
-      typedef RootDataConnection::LinkSections LinkSections;
-      typedef RootDataConnection::ContainerSection ContainerSection;
+      typedef RootDataConnection::StringVec         StringVec;
+      typedef RootDataConnection::ParamMap          ParamMap;
+      typedef RootDataConnection::Sections          Sections;
+      typedef RootDataConnection::MergeSections     MergeSections;
+      typedef RootDataConnection::LinkSections      LinkSections;
+      typedef RootDataConnection::ContainerSection  ContainerSection;
       typedef RootDataConnection::ContainerSections ContainerSections;
 
       /// Pointer to containing data connection object
       RootDataConnection* c;
 
     public:
-      TTree* refs() const { return c->m_refs; }
-      StringVec& dbs() const { return c->m_dbs; }
-      StringVec& conts() const { return c->m_conts; }
-      StringVec& links() const { return c->m_links; }
-      ParamMap& params() const { return c->m_params; }
-      MsgStream& msgSvc() const { return c->msgSvc(); }
+      TTree*             refs() const { return c->m_refs; }
+      StringVec&         dbs() const { return c->m_dbs; }
+      StringVec&         conts() const { return c->m_conts; }
+      StringVec&         links() const { return c->m_links; }
+      ParamMap&          params() const { return c->m_params; }
+      MsgStream&         msgSvc() const { return c->msgSvc(); }
       const std::string& name() const { return c->m_name; }
-      Sections& sections() const { return c->m_sections; }
-      LinkSections& linkSections() const { return c->m_linkSects; }
-      MergeSections& mergeSections() const { return c->m_mergeSects; }
+      Sections&          sections() const { return c->m_sections; }
+      LinkSections&      linkSections() const { return c->m_linkSects; }
+      MergeSections&     mergeSections() const { return c->m_mergeSects; }
 
       /// Default destructor
       virtual ~Tool() = default;
-- 
GitLab