diff --git a/Database/IOVDbSvc/share/IOVDbSvc_test.ref b/Database/IOVDbSvc/share/IOVDbSvc_test.ref
index 64a1c3298599c1d079babf731d5b301744d475e5..a1aad4a66be5d7e878326eb7e3bedeb65fded857 100644
--- a/Database/IOVDbSvc/share/IOVDbSvc_test.ref
+++ b/Database/IOVDbSvc/share/IOVDbSvc_test.ref
@@ -2,7 +2,7 @@ IOVDbSvc_test
 
 
 Initializing Gaudi ApplicationMgr using job opts ../share/IOVDbSvc_test.txt
-JobOptionsSvc        INFO # =======> /afs/cern.ch/work/s/ssnyder/builds/atlas-work3/build-x86_64-slc6-gcc62-dbg/Database/IOVDbSvc/unitTestRun/../share/IOVDbSvc_test.txt
+JobOptionsSvc        INFO # =======> user_path/athena/Database/IOVDbSvc/share/../share/IOVDbSvc_test.txt
 JobOptionsSvc        INFO # (1,1): ApplicationMgr.CreateSvc += ["StoreGateSvc/DetectorStore"]
 JobOptionsSvc        INFO # (2,1): IOVDbSvc.Folders = ["/key1", "/key2<extensible/>"]
 JobOptionsSvc        INFO # (3,1): EventPersistencySvc.CnvServices += ["AthenaPoolCnvSvc"]
@@ -10,7 +10,7 @@ JobOptionsSvc        INFO Job options successfully read in from ../share/IOVDbSv
 ApplicationMgr    SUCCESS 
 ====================================================================================================================================
                                                    Welcome to ApplicationMgr (GaudiCoreSvc v30r4)
-                                          running on lxplus051.cern.ch on Sat Nov 10 04:16:03 2018
+                                          running on lxplus021.cern.ch on Mon Nov 19 14:46:10 2018
 ====================================================================================================================================
 ApplicationMgr       INFO Application Manager Configured successfully
 ClassIDSvc           INFO  getRegistryEntries: read 642 CLIDRegistry entries for module ALL
@@ -23,8 +23,8 @@ PoolSvc              INFO io_register[PoolSvc](xmlcatalog_file:PoolFileCatalog.x
 PoolSvc              INFO Set connectionsvc retry/timeout/IDLE timeout to  'ConnectionRetrialPeriod':300/ 'ConnectionRetrialTimeOut':3600/ 'ConnectionTimeOut':5 seconds with connection cleanup disabled
 PoolSvc              INFO Frontier compression level set to 5
 DBReplicaSvc         INFO Frontier server at (serverurl=http://atlasfrontier-local.cern.ch:8000/atlr)(serverurl=http://atlasfrontier-ai.cern.ch:8000/atlr)(serverurl=http://lcgft-atlas.gridpp.rl.ac.uk:3128/frontierATLAS)(serverurl=http://ccfrontier.in2p3.fr:23128/ccin2p3-AtlasFrontier)(proxyurl=http://ca-proxy.cern.ch:3128)(proxyurl=http://ca-proxy-meyrin.cern.ch:3128)(proxyurl=http://ca-proxy-wigner.cern.ch:3128)(proxyurl=http://atlasbpfrontier.cern.ch:3127)(proxyurl=http://atlasbpfrontier.fnal.gov:3127) will be considered for COOL data
-DBReplicaSvc         INFO Read replica configuration from /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2018-11-08T2259/Athena/22.0.1/InstallArea/x86_64-slc6-gcc62-dbg/share/dbreplica.config
-DBReplicaSvc         INFO Total of 10 servers found for host lxplus051.cern.ch [ATLF ATLAS_COOLPROD atlas_dd ATLAS_CONFIG INT8R INTR ATONR_COOL ATONR_CONF DEVDB11 ATLF ]
+DBReplicaSvc         INFO Read replica configuration from /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2018-11-17T2340/Athena/22.0.1/InstallArea/x86_64-slc6-gcc8-opt/share/dbreplica.config
+DBReplicaSvc         INFO Total of 10 servers found for host lxplus021.cern.ch [ATLF ATLAS_COOLPROD atlas_dd ATLAS_CONFIG INT8R INTR ATONR_COOL ATONR_CONF DEVDB11 ATLF ]
 PoolSvc              INFO Successfully setup replica sorting algorithm
 PoolSvc              INFO Setting up APR FileCatalog and Streams
 PoolSvc              INFO POOL WriteCatalog is xmlcatalog_file:PoolFileCatalog.xml
@@ -32,7 +32,7 @@ DbSession            INFO     Open     DbSession
 Domain[ROOT_All]     INFO >   Access   DbDomain     READ      [ROOT_All] 
 IOVDbSvc             INFO Opened read transaction for POOL PersistencySvc
 IOVDbSvc             INFO Only 5 POOL conditions files will be open at once
-IOVDbSvc             INFO Extensible folder /key2
+IOVDbFolder          INFO Extensible folder /key2
 IOVDbSvc             INFO Initialised with 1 connections and 2 folders
 IOVDbSvc             INFO Service IOVDbSvc initialised successfully
 IOVDbSvc             INFO Opening COOL connection for sqlite://;schema=cooldummy.db;dbname=OFLP200
@@ -44,6 +44,6 @@ IOVDbSvc             INFO Opening COOL connection for sqlite://;schema=cooldummy
 IOVDbSvc             INFO Disconnecting from sqlite://;schema=cooldummy.db;dbname=OFLP200
 AthenaPoolCnvSvc     INFO Initializing AthenaPoolCnvSvc - package version AthenaPoolCnvSvc-00-00-00
 EventPersistenc...   INFO Added successfully Conversion service:AthenaPoolCnvSvc
-IOVDbSvc             INFO Increase cache length (step 1) for folder /key2 to 8589934590 at validityKey 85899345935
+IOVDbFolder          INFO Increase cache length (step 1) for folder /key2 to 8589934590 at validityKey 85899345935
 IOVDbSvc             INFO Opening COOL connection for sqlite://;schema=cooldummy.db;dbname=OFLP200
-IOVDbSvc             INFO Disconnecting from sqlite://;schema=cooldummy.db;dbname=OFLP200
+IOVDbSvc             INFO Disconnecting from sqlite://;schema=cooldummy.db;dbname=OFLP200
\ No newline at end of file
diff --git a/Database/IOVDbSvc/src/FolderTypes.cxx b/Database/IOVDbSvc/src/FolderTypes.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..30df55a01ca0eec719668aee31732d9814e12fea
--- /dev/null
+++ b/Database/IOVDbSvc/src/FolderTypes.cxx
@@ -0,0 +1,79 @@
+#include "FolderTypes.h"
+#include "AthenaKernel/IClassIDSvc.h"
+#include "IOVDbStringFunctions.h"
+#include "CoolKernel/IRecordSpecification.h"
+#include "AthenaPoolUtilities/CondAttrListCollection.h"
+#include <vector>
+
+namespace IOVDbNamespace{
+  //determine folder type from DB folder ptr
+  FolderType
+  determineFolderType(const cool::IFolderPtr & pFolder, IClassIDSvc* /*clidsvc*/){
+    const auto & folderDescription = pFolder->description();
+    //int clid = parseClid(folderDescription);
+    //If you find a coracool tag, it is unambiguously a coracool folder
+    std::cout<<folderDescription<<std::endl;
+    if (folderDescription.find("<coracool>") != std::string::npos) return CoraCool;
+    const std::string typeName = parseTypename(folderDescription);
+    std::cout<<typeName<<std::endl;
+    //if the type is CondAttrListVec, and yet it is not a CoraCool, it must be a CoolVector
+    if (typeName=="CondAttrListVec") return CoolVector;
+    //check if the payload spec is compatible with a pool ref/pool ref collection
+    if (poolCompatible(pFolder->payloadSpecification())){
+      const auto & chans=pFolder->listChannels();
+      const auto nchans = chans.size();
+      const bool onlyOneSpecialChannel = ((nchans == 1) and (chans[0] == 0));
+      return onlyOneSpecialChannel ? PoolRef : PoolRefColl;
+    }
+    if (typeName == "CondAttrListCollection") return AttrListColl;
+    //defaults to AttrList
+    return AttrList;
+   }
+   
+   //determine folder type from CondAttrListCollection ptr
+   FolderType
+   determineFolderType(const CondAttrListCollection * pAttrListColl){
+     FolderType ftype(AttrList);
+     //has a single magic channel?
+     if (pAttrListColl->size()==1 && pAttrListColl->begin()->first==0xFFFF) {
+       if (poolCompatible (pAttrListColl)) return PoolRef;
+       return AttrList;
+     } else {
+       ftype=AttrListColl;
+       if ( pAttrListColl->size()>0) {
+         if (poolCompatible (pAttrListColl)) return PoolRefColl;
+       }
+     }
+     return ftype;
+   }
+   
+   FolderType
+   determineFolderType(const coral::AttributeSpecification& spec){
+     FolderType result(UNKNOWN);
+     if (spec.name()=="PoolRef" && spec.typeName()=="string") result = PoolRef;
+     return result;
+   }
+   
+   bool
+   poolCompatible(const cool::IRecordSpecification& rspec){
+     return (rspec.exists("PoolRef") && rspec[0].name()=="PoolRef" &&
+      rspec[0].storageType()==cool::StorageType::String4k);
+   }
+   
+   bool
+   poolCompatible(const CondAttrListCollection * pAttrListColl){
+     const coral::AttributeList& payload1=pAttrListColl->begin()->second;
+     const coral::AttributeSpecification& spec=payload1[0].specification();
+     return (spec.name()=="PoolRef" && spec.typeName()=="string");
+   }
+   
+   std::string
+   folderTypeName(const FolderType f){
+      static const std::vector<std::string> names{"AttrList", "AttrListColl", "PoolRef",
+      "PoolRefColl", "CoraCool", "CoolVector", "JSON"};
+      if (f==UNKNOWN) return "Unknown";
+      return names[f];
+   }
+
+}
+
diff --git a/Database/IOVDbSvc/src/FolderTypes.h b/Database/IOVDbSvc/src/FolderTypes.h
new file mode 100644
index 0000000000000000000000000000000000000000..076b11d916e18661e784e3e246862e5cb31096d5
--- /dev/null
+++ b/Database/IOVDbSvc/src/FolderTypes.h
@@ -0,0 +1,58 @@
+/*
+  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+*/
+// @file FolderTypes.h
+// Header for FolderTypes utilities
+// @author Shaun Roe
+// @date 05 October 2017
+#ifndef FolderTypes_H
+#define FolderTypes_H
+
+#include "CoolKernel/IFolder.h"
+#include "CoolKernel/pointers.h" //IFolderPtr etc, typdefs
+#include <string>
+
+class IClassIDSvc;
+class CondAttrListCollection;
+
+namespace cool{
+  class IRecordSpecification;
+}
+
+
+namespace IOVDbNamespace{
+  //basic folder types
+  enum FolderType {
+    UNKNOWN=-1,
+    AttrList=0,
+    AttrListColl,
+    PoolRef,
+    PoolRefColl,
+    CoraCool,
+    CoolVector,
+    JSON,
+    NUM_FOLDER_TYPES
+   };
+   
+   //determine folder type with optional check using clid service to check clid matches typename
+   FolderType
+   determineFolderType(const cool::IFolderPtr & pFolder, IClassIDSvc* clidsvc=nullptr);
+   
+   std::string
+   folderTypeName(const FolderType f);
+   
+   FolderType
+   determineFolderType(const CondAttrListCollection * pAttrListColl);
+   
+   FolderType
+   determineFolderType(const coral::AttributeSpecification& spec);
+   
+   bool
+   poolCompatible(const cool::IRecordSpecification& rspec);
+   
+   bool
+   poolCompatible(const CondAttrListCollection * pAttrListColl);
+}
+
+#endif
+
diff --git a/Database/IOVDbSvc/src/IOVDbConn.cxx b/Database/IOVDbSvc/src/IOVDbConn.cxx
index 4fed0ef4388ae489efa8fb2d9ac0a67a04fda046..a5cfd257a7af5a13291b23910b8709420d046af2 100644
--- a/Database/IOVDbSvc/src/IOVDbConn.cxx
+++ b/Database/IOVDbSvc/src/IOVDbConn.cxx
@@ -15,7 +15,7 @@
 #include "IOVDbConn.h"
 
 IOVDbConn::IOVDbConn(const std::string& dbname, const bool readOnly, 
-                     MsgStream* msg) :
+                     MsgStream & msg) :
   m_log(msg),
   m_active(false),
   m_readonly(readOnly),
@@ -32,14 +32,14 @@ cool::IDatabasePtr IOVDbConn::getCoolDb() {
   if (m_coolDb.get()==0) {
     // check connection not already aborted
     if (m_abort) {
-      *m_log << MSG::ERROR << "COOL connection for " << m_connstr << 
+      m_log << MSG::ERROR << "COOL connection for " << m_connstr << 
         " already aborted as invalid" << endmsg;
       // in this case, return the null connection ptr immediately to avoid
       // another full attempt to connect
       return m_coolDb;
     }
     // open new connection
-    *m_log << MSG::INFO << "Opening COOL connection for " << m_connstr << 
+    m_log << MSG::INFO << "Opening COOL connection for " << m_connstr << 
       endmsg;
     ++m_nconn;
     cool::IDatabaseSvc& dbSvc=cool::DatabaseSvcFactory::databaseService();
@@ -49,18 +49,18 @@ cool::IDatabasePtr IOVDbConn::getCoolDb() {
     }
     catch (std::exception& e) {
       // create a new COOL conditions DB
-      *m_log << MSG::INFO << "*** COOL  exception caught: " << e.what() 
+      m_log << MSG::INFO << "*** COOL  exception caught: " << e.what() 
              << endmsg;
-      *m_log << MSG::INFO << "Create a new conditions database: " << m_connstr
+      m_log << MSG::INFO << "Create a new conditions database: " << m_connstr
              << endmsg;
       try {
         m_coolDb=dbSvc.createDatabase(m_connstr);
         m_active=true;
       }
       catch (std::exception&e ) {
-        *m_log << MSG::ERROR << "*** COOL  exception caught: " << e.what() 
+        m_log << MSG::ERROR << "*** COOL  exception caught: " << e.what() 
                << endmsg;
-        *m_log << MSG::ERROR << 
+        m_log << MSG::ERROR << 
           "Could not create a new conditions database - abort connection"
                << endmsg;
         m_abort=true;
@@ -75,7 +75,7 @@ CoraCoolDatabasePtr IOVDbConn::getCoraCoolDb() {
   // only open if not already activated
   if (m_coracoolDb.get()==0) {
     // open new connection
-    *m_log << MSG::INFO << "Opening CoraCool connection for " << m_connstr << 
+    m_log << MSG::INFO << "Opening CoraCool connection for " << m_connstr << 
       endmsg;
     coral::ConnectionService connSvc;
     m_coracoolDb=CoraCoolDatabasePtr(new CoraCoolDatabase(m_connstr,
@@ -87,24 +87,24 @@ CoraCoolDatabasePtr IOVDbConn::getCoraCoolDb() {
 
 void IOVDbConn::setInactive() {
   if (m_coolDb.get()!=0) {
-    *m_log << MSG::INFO << "Disconnecting from " << m_connstr << endmsg;
+    m_log << MSG::INFO << "Disconnecting from " << m_connstr << endmsg;
     try {
       m_coolDb->closeDatabase();
     }
     catch (std::exception& e) {
-      *m_log << MSG::INFO << "Exception caught when disconnecting: " <<
+      m_log << MSG::INFO << "Exception caught when disconnecting: " <<
         e.what() << endmsg;
     }
     m_coolDb.reset();
   }
   if (m_coracoolDb.get()!=0) {
-    *m_log << MSG::INFO << "Disconnecting CoraCool from " << m_connstr << 
+    m_log << MSG::INFO << "Disconnecting CoraCool from " << m_connstr << 
       endmsg;
     try { 
       m_coracoolDb->disconnect();
     }
     catch (std::exception& e) {
-      *m_log << MSG::INFO << "Exception caught when disconnecting CoraCool: " 
+      m_log << MSG::INFO << "Exception caught when disconnecting CoraCool: " 
              << e.what() << endmsg;
     }
     m_coracoolDb.reset();
@@ -121,7 +121,7 @@ void IOVDbConn::setReadOnly(const bool readOnly) {
 
 void IOVDbConn::summary(const float fread) {
   // print summary of usage
-  *m_log << MSG::INFO << "Connection " << m_connstr << " : nConnect: " <<
+  m_log << MSG::INFO << "Connection " << m_connstr << " : nConnect: " <<
     m_nconn << " nFolders: " << m_nfolder <<  " ReadTime: (( " << std::fixed <<
     std::setw(8) << std::setprecision(2) << fread << " ))s" << endmsg;
 }
diff --git a/Database/IOVDbSvc/src/IOVDbConn.h b/Database/IOVDbSvc/src/IOVDbConn.h
index bd213cc12ee6053db9715cbc522cd3f0243073a5..dc30011a6112c7010f3c1597d701039aa24b697e 100644
--- a/Database/IOVDbSvc/src/IOVDbConn.h
+++ b/Database/IOVDbSvc/src/IOVDbConn.h
@@ -15,7 +15,7 @@ class MsgStream;
 
 class IOVDbConn {
  public:
-  IOVDbConn(const std::string& dbname, const bool readOnly, MsgStream* msg);
+  IOVDbConn(const std::string& dbname, const bool readOnly, MsgStream & msg);
   ~IOVDbConn();
 
   bool isActive() const;
@@ -33,7 +33,7 @@ class IOVDbConn {
   void setReadOnly(const bool readOnly);
 
  private:
-  MsgStream* m_log;
+  MsgStream & m_log;
   bool m_active;
   bool m_readonly;
   bool m_abort;
diff --git a/Database/IOVDbSvc/src/IOVDbCoolFunctions.h b/Database/IOVDbSvc/src/IOVDbCoolFunctions.h
new file mode 100644
index 0000000000000000000000000000000000000000..b947b27c7aa1e8951e271a6a4225b9312f778196
--- /dev/null
+++ b/Database/IOVDbSvc/src/IOVDbCoolFunctions.h
@@ -0,0 +1,30 @@
+/*
+  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+*/
+//@file IOVDbCoolFunctions.h
+//@brief Numeric and COOL/Coral dependent helper functions
+//@author Shaun Roe
+
+#include <utility>
+#include <vector>
+#include <algorithm>
+
+namespace IOVDbNamespace{
+
+  //!Function to check whether a number is in the inclusive range, given as a pair.
+  //!Typically used with Channel ranges for COOL
+  template <class NumericType>
+  bool
+  inRange(const NumericType & val, const std::pair<NumericType, NumericType> & range){
+    return (val>=range.first && val<=range.second);
+  }
+  
+  template <class NumericType>
+  bool
+  inRange(const NumericType & val, const std::vector<std::pair<NumericType, NumericType> > & ranges){
+    auto valueInRange=[val](const std::pair<NumericType, NumericType> & range){ return inRange(val,range); };
+    return std::any_of(ranges.begin(), ranges.end(), valueInRange);
+  }
+  
+
+}
\ No newline at end of file
diff --git a/Database/IOVDbSvc/src/IOVDbFolder.cxx b/Database/IOVDbSvc/src/IOVDbFolder.cxx
index 64dd3acdfaac95b93826f218a9d09ff88b91df65..31f4d90a1986b14fb66b8444e2b8a4bd4ad1d458 100644
--- a/Database/IOVDbSvc/src/IOVDbFolder.cxx
+++ b/Database/IOVDbSvc/src/IOVDbFolder.cxx
@@ -8,12 +8,14 @@
 #include <sstream>
 #include <stdexcept>
 
-#include "GaudiKernel/MsgStream.h"
+
 #include "GaudiKernel/Bootstrap.h"
 #include "GaudiKernel/IOpaqueAddress.h"
 #include "GaudiKernel/GenericAddress.h"
 #include "GaudiKernel/IAddressCreator.h"
 #include "GaudiKernel/ISvcLocator.h"
+
+
 #include "StoreGate/StoreGateSvc.h"
 #include "CoolKernel/IObject.h"
 #include "CoolKernel/IObjectIterator.h"
@@ -47,14 +49,18 @@
 #include "IOVDbConn.h"
 
 #include "IOVDbFolder.h"
+#include "IOVDbStringFunctions.h"
+#include "IOVDbCoolFunctions.h"
 #include "CxxUtils/make_unique.h"
 
+using namespace IOVDbNamespace;
+
 
 
 IOVDbFolder::IOVDbFolder(IOVDbConn* conn,
-                         const IOVDbParser& folderprop, MsgStream* msg,
+                         const IOVDbParser& folderprop, MsgStream & /*msg*/,
                          IClassIDSvc* clidsvc, const bool checklock):
-  m_log(msg),
+  
   p_detStore(0),
   p_clidSvc(clidsvc),
   p_metaDataTool(0),
@@ -102,7 +108,8 @@ IOVDbFolder::IOVDbFolder(IOVDbConn* conn,
   m_boundmin(),
   m_boundmax(),
   m_nboundmin(0),
-  m_nboundmax(0)
+  m_nboundmax(0),
+  m_msg("IOVDbFolder")
 {
   // extract settings from the properties
   // foldername from the 'unnamed' property
@@ -120,90 +127,67 @@ IOVDbFolder::IOVDbFolder(IOVDbConn* conn,
   std::string buf;
   // check for <noover> - disables using tag override read from input file
   m_notagoverride=folderprop.getKey("noover","",buf);
-  if (m_notagoverride) *m_log << MSG::INFO << 
-                         "Inputfile tag override disabled for " << m_foldername << endmsg;
+  if (m_notagoverride) ATH_MSG_INFO( "Inputfile tag override disabled for " << m_foldername );
 
   // channel selection from 'channelSelection' property
   // syntax is A:B,C:D,E:F
   // :B implies zero lower limit, A: implies zero upper limit
   std::string chanspec,rangespec;
   if (folderprop.getKey("channelSelection","",chanspec) && chanspec!="") {
+    m_chanrange=IOVDbNamespace::parseChannelSpec<cool::ChannelId>(chanspec);
     // explicit setting of channel selection
-    bool first=true;
-    std::string::size_type index;
-    do {
-      index=chanspec.find(',');
-      if (index!=std::string::npos) {
-        rangespec=chanspec.substr(0,index);
-        chanspec=chanspec.substr(index+1,chanspec.size());
-      } else {
-        rangespec=chanspec;
-      }
-      if (rangespec!="") {
-        // parse the range specification, look for : separator between limits
-        std::string::size_type icol=rangespec.find(':');
-        cool::ChannelId lower,upper;
-        if (icol!=std::string::npos) {
-          lower=makeChannel(spaceStrip(rangespec.substr(0,icol)),0);
-          upper=makeChannel(spaceStrip(rangespec.substr(
-                                                        icol+1,rangespec.size())),std::numeric_limits<cool::ChannelId>::max());
-        } else {
-          lower=atol(spaceStrip(rangespec).c_str());
-          upper=lower;
-        }
-        *m_log << MSG::INFO << "Add channel range " << lower << ":" << upper 
-               << " for folder " << m_foldername << endmsg;
-        if (first) {
-          m_chansel=cool::ChannelSelection(lower,upper);
-          first=false;
+    bool first(true);
+    //push to the channel selection
+    try{
+      for(const auto & i:m_chanrange){
+        if (first){
+          first = false;
+          m_chansel = cool::ChannelSelection(i.first,i.second);
         } else {
-          // COOL gives error if range is not given in pure ascending
-          // or descending order
-          try {
-            m_chansel.addRange(lower,upper);
-          }
-          catch (cool::Exception& e) {
-            *m_log << MSG::ERROR  <<  
-              "defining channel range (must be given in ascending order)" 
-                   << endmsg;
-            throw;
-          }
+          m_chansel.addRange(i.first,i.second);
         }
-        m_chanrange.push_back(ChanRange(lower,upper));
       }
-    } while (index!=std::string::npos);
-    *m_log << MSG::INFO << "Channel selection for folder " << m_foldername << 
-      " with " << m_chanrange.size() << " ranges" << endmsg;
+    } catch (cool::Exception& e) {
+        ATH_MSG_ERROR("defining channel range (must be given in ascending order)");
+        throw;
+    }
   }
   // check for folder-specific run/LB/time overrides
   if (folderprop.getKey("forceRunNumber","",buf)) {
-    unsigned long long run=atoi(buf.c_str());
+    const auto run = IOVDbNamespace::iovFromRunString(buf);
     unsigned int lb=0;
-    if (folderprop.getKey("forceLumiblockNumber","",buf)) lb=atoi(buf.c_str());
-    m_iovoverridden=true;
-    m_iovoverride=(run << 32LL)+lb;
-    *m_log << MSG::INFO << 
-      "Override run/LB number to [" << run << ":" << lb << 
-      "] for folder " << m_foldername << endmsg;
+    if (folderprop.getKey("forceLumiblockNumber","",buf)) lb=IOVDbNamespace::iovFromLumiBlockString(buf);
+    overrideWithRunLumi(run, lb);
   }
   if (folderprop.getKey("forceTimestamp","",buf)) {
-    unsigned int time=atoi(buf.c_str());
-    m_iovoverridden=true;
-    m_iovoverride=time*1000000000LL;
-    *m_log << MSG::INFO << "Override timestamp to " << m_iovoverride << 
-      " for folder " << m_foldername << endmsg;
+    const auto ts=IOVDbNamespace::iovFromTimeString(buf);
+    overrideWithTimestamp(ts);
   }
   m_fromMetaDataOnly=folderprop.getKey("metaOnly","",buf);
   if (m_fromMetaDataOnly) {
-    *m_log << MSG::INFO << "Read from meta data only for folder " << m_foldername << endmsg;
+    ATH_MSG_INFO( "Read from meta data only for folder " << m_foldername );
   }
 
   m_extensible=folderprop.getKey("extensible","",buf);
   if (m_extensible) {
-    *m_log << MSG::INFO << "Extensible folder " << m_foldername << endmsg;
+    ATH_MSG_INFO( "Extensible folder " << m_foldername );
   }
 }
 
+void
+IOVDbFolder::overrideWithRunLumi(const unsigned long long run, const unsigned long long lb){
+  m_iovoverridden=true;
+  m_iovoverride=run+lb;
+  ATH_MSG_INFO( "Override run/LB number to [" << run << ":" << lb << "] for folder " << m_foldername );
+}
+
+void
+IOVDbFolder::overrideWithTimestamp(const unsigned long long timestamp){
+  m_iovoverridden=true;
+  m_iovoverride = timestamp;
+  ATH_MSG_INFO( "Override timestamp to " << m_iovoverride << " for folder " << m_foldername );
+}
+
 IOVDbFolder::~IOVDbFolder() {
   if (m_cachespec!=0) m_cachespec->release();
 }
@@ -220,13 +204,12 @@ void IOVDbFolder::setMetaCon(const IOVMetaDataContainer* metacon) {
 
 void IOVDbFolder::setTagOverride(const std::string& tag,const bool setFlag) {
   if (m_tagoverride) {
-    *m_log << MSG::WARNING << "Request to override tag for folder " <<
-      m_foldername << " to " << tag << " supercedes earlier override to " 
-           << m_jotag << endmsg;
+    ATH_MSG_WARNING( "Request to override tag for folder " <<
+      m_foldername << " to " << tag << " supercedes earlier override to "  << m_jotag );
   } else {
     if (setFlag) m_tagoverride=true;
   }
-  m_jotag=spaceStrip(tag);
+  m_jotag=IOVDbNamespace::spaceStrip(tag);
 }
 
 void IOVDbFolder::setWriteMeta(IIOVDbMetaDataTool* metadatatool) {
@@ -243,17 +226,17 @@ void IOVDbFolder::setIOVOverride(const unsigned int run,
   if (m_timestamp) {
     if (time!=0) {
       m_iovoverride=(static_cast<unsigned long long>(time))*1000000000LL;
-      *m_log << MSG::INFO << 
+      ATH_MSG_INFO( 
         "Override timestamp to " << m_iovoverride << " for folder "
-             << m_foldername << endmsg;
+             << m_foldername );
       m_iovoverridden=true;
     }
   } else {
     if (run!=0 || lumiblock!=0) {
       m_iovoverride=((static_cast<unsigned long long>(run)) << 32LL)+lumiblock;
-      *m_log << MSG::INFO << 
+      ATH_MSG_INFO( 
         "Override run/LB number to [" << run << ":" << lumiblock << 
-        "] for folder " << m_foldername << endmsg;
+        "] for folder " << m_foldername );
       m_iovoverridden=true;
     }
   }
@@ -266,10 +249,7 @@ cool::ValidityKey IOVDbFolder::iovTime(const IOVTime& reftime) const {
   if (m_iovoverridden) {
     return m_iovoverride;
   } else {
-    if (m_timestamp)
-      return reftime.timestamp();
-    else 
-      return reftime.re_time();
+    return (m_timestamp ? reftime.timestamp() : reftime.re_time());
   }
 }
 
@@ -286,18 +266,16 @@ bool IOVDbFolder::loadCache(const cool::ValidityKey vkey,
   // timer to track amount of time in loadCache
   TStopwatch cachetimer;
 
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "IOVDbFolder::loadCache for folder " << m_foldername 
-           << " validitykey " << vkey << endmsg;
+  ATH_MSG_DEBUG( "Load cache for folder " << m_foldername << " validitykey " << vkey);
   // if not first time through, and limit not reached,and cache was not reset, 
   // and we are going forwards in time, double cachesize
   if (m_ndbread>0 && m_cacheinc<3 && (m_cachestop!=m_cachestart) && 
       vkey>m_cachestart &&m_autocache) {
     m_cachelength*=2;
     ++m_cacheinc;
-    *m_log << MSG::INFO << "Increase cache length (step " << m_cacheinc << 
+    ATH_MSG_INFO( "Increase cache length (step " << m_cacheinc << 
       ") for folder " << m_foldername
-           << " to " << m_cachelength << " at validityKey " << vkey << endmsg;
+           << " to " << m_cachelength << " at validityKey " << vkey );
   }
   ++m_ndbread;
   if (cacheDiv>0) {
@@ -316,9 +294,8 @@ bool IOVDbFolder::loadCache(const cool::ValidityKey vkey,
     m_cachestop=vkey+m_cachelength;
   }
   if (m_cachestop>cool::ValidityKeyMax) m_cachestop=cool::ValidityKeyMax;
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "IOVDbFolder:loadCache limits set to [" 
-           << m_cachestart << "," << m_cachestop << "]" << endmsg;
+  ATH_MSG_DEBUG( "IOVDbFolder:loadCache limits set to [" 
+           << m_cachestart << "," << m_cachestop << "]" );
 
   if (m_cachespec==0) {
     // on first init, guess size based on channel count
@@ -349,18 +326,14 @@ bool IOVDbFolder::loadCache(const cool::ValidityKey vkey,
   // query to fill cache - request for database activates connection
   cool::IDatabasePtr dbPtr=m_conn->getCoolDb();
   if (dbPtr.get()==0) {
-    *m_log << MSG::FATAL << "Conditions database connection " <<
-      m_conn->name() << " cannot be opened - STOP" << endmsg;
+    ATH_MSG_FATAL( "Conditions database connection " <<
+      m_conn->name() << " cannot be opened - STOP" );
     return false;
   }
   // access COOL inside try/catch in case of using stale connection
   unsigned int attempts=0;
   bool retrievedone=false;
-  // check if explicit checking of channels is required to work around COOL
-  // bug 42708
-  // bool checkChan=(m_chanrange.size()>1);
-  // now relying on COOL channel selection alone
-  bool checkChan=false;
+  
   while (attempts<2 && !retrievedone) {
     ++attempts;
     try {
@@ -371,30 +344,24 @@ bool IOVDbFolder::loadCache(const cool::ValidityKey vkey,
       // if a selection is in use, count them explicitly
       if (m_chanrange.size()>0) {
         m_nboundmin=0;
-        for (std::vector<cool::ChannelId>::const_iterator citr=
-               m_channums.begin();citr!=m_channums.end();++citr) {
-          // if (isChanSelected(*citr)) ++m_nboundmin;
+        for (const auto & thisChannel:m_channums) {
           // use internal COOL channel selection
-          if (m_chansel.inSelection(*citr)) ++m_nboundmin;
+          if (m_chansel.inSelection(thisChannel)) ++m_nboundmin;
         }
       } else {
         m_nboundmin=m_nchan;
       }
-      if (m_log->level()<=MSG::DEBUG)
-        *m_log << MSG::DEBUG << "Expecting to see " << m_nboundmin << 
-          " channels" << endmsg;
+      ATH_MSG_DEBUG( "Expecting to see " << m_nboundmin << " channels" );
       m_nboundmax=m_nboundmin;
       // check pointer is still valid - can go stale in AthenaMT environment
       // according to CORAL server tests done by Andrea Valassi (23/6/09)
-      if (dbPtr.get()==0) throw std::runtime_error(
-                                                   "COOL database pointer invalidated");
+      if (not dbPtr.get()) throw std::runtime_error("COOL database pointer invalidated");
       // access COOL folder in case needed to resolve tag (even for CoraCool)
       cool::IFolderPtr folder=dbPtr->getFolder(m_foldername);
       // resolve the tag for MV folders if not already done so
       if (m_multiversion && m_tag=="") {
         if (!resolveTag(folder,globalTag)) return false;
-        if (m_log->level()<=MSG::DEBUG) 
-          *m_log << MSG::DEBUG << "resolveTag returns " << m_tag << endmsg;
+        ATH_MSG_DEBUG( "resolveTag returns " << m_tag);
       }
       if (m_foldertype==CoraCool) {
         // CoraCool retrieve
@@ -405,8 +372,6 @@ bool IOVDbFolder::loadCache(const cool::ValidityKey vkey,
                                                           m_cachestop,m_chansel,m_tag);
         while (itr->hasNext()) {
           CoraCoolObjectPtr obj=itr->next();
-          // skip channels which are explicitly vetoed by range
-          if (checkChan && !isChanSelected(obj->channelId()))  continue;
           addIOVtoCache(obj->since(),obj->until());
           m_cachechan.push_back(obj->channelId());
           // store all the attributeLists in the buffer
@@ -433,8 +398,6 @@ bool IOVDbFolder::loadCache(const cool::ValidityKey vkey,
                                                            m_cachestop,m_chansel,m_tag);
         while (itr->goToNext()) {
           const cool::IObject& ref=itr->currentRef();
-          // skip channels which are explicitly vetoed by range
-          if (checkChan && !isChanSelected(ref.channelId())) continue;
           addIOVtoCache(ref.since(),ref.until());
           m_cachechan.push_back(ref.channelId());
 
@@ -475,64 +438,56 @@ bool IOVDbFolder::loadCache(const cool::ValidityKey vkey,
         itr->close();
         retrievedone=true;
       }
-      if (m_log->level()<=MSG::DEBUG) 
-        *m_log << MSG::DEBUG << "Retrieved " << iadd << " objects for " 
-               << m_nchan << " channels into cache" << endmsg;
+      ATH_MSG_DEBUG( "Retrieved " << iadd << " objects for "<< m_nchan << " channels into cache" );
       m_nobjread+=iadd;
     }
     catch (std::exception& e) {
-      *m_log << MSG::WARNING << "COOL retrieve attempt " << attempts << 
-        " failed: " << e.what() << endmsg;
+      ATH_MSG_WARNING( "COOL retrieve attempt " << attempts << 
+        " failed: " << e.what() );
       // disconnect and reconnect
       try {
         m_conn->setInactive();
         dbPtr=m_conn->getCoolDb();
       }
       catch (std::exception& e) {
-        *m_log << MSG::WARNING << "Exception from disconnect/reconnect: " << 
-          e.what() << endmsg;
+        ATH_MSG_WARNING( "Exception from disconnect/reconnect: " <<e.what() );
         // try once more to connect
         try {
           dbPtr=m_conn->getCoolDb();
         }
         catch (std::exception& e) {
-          *m_log << MSG::ERROR << "Cannot reconnect to database:" << e.what()
-                 << endmsg;
+          ATH_MSG_ERROR( "Cannot reconnect to database:" << e.what());
         }
       }
     }
   }
 
   if (!retrievedone) {
-    *m_log << MSG::ERROR << "Could not retrieve COOL data for folder " <<
+    ATH_MSG_ERROR( "Could not retrieve COOL data for folder " <<
       m_foldername << " tag " << m_tag << " validityKeys [" << m_cachesince <<
-      "," << m_cacheuntil << "]" << endmsg;
+      "," << m_cacheuntil << "]" );
     return false;
   }
   // check if cache can be stretched according to extent of IOVs crossing
   // boundaries - this requires all channels to have been seen
-  if (m_log->level()<=MSG::DEBUG)
-    *m_log << MSG::DEBUG << "Cache retrieve missing " << m_nboundmin 
-           << " lower and " << m_nboundmax << " upper channels" << endmsg;
+  ATH_MSG_DEBUG( "Cache retrieve missing " << m_nboundmin 
+           << " lower and " << m_nboundmax << " upper channels" );
   if ((m_nboundmin==0 || ignoreMissChan) && m_boundmin < m_cachestart) {
-    if (m_log->level()<=MSG::DEBUG)
-      *m_log << MSG::DEBUG << "Lower cache limit extended from " 
-             << m_cachestart << " to " << m_boundmin << endmsg;
+    ATH_MSG_DEBUG( "Lower cache limit extended from " 
+             << m_cachestart << " to " << m_boundmin );
     m_cachestart=m_boundmin;
   }
   if ((m_nboundmax==0 || ignoreMissChan) && m_boundmax > m_cachestop) {
-    if (m_log->level()<=MSG::DEBUG)
-      *m_log << MSG::DEBUG << "Upper cache limit extended from " <<
-        m_cachestop << " tp " << m_boundmax << endmsg;
+    ATH_MSG_DEBUG( "Upper cache limit extended from " <<
+        m_cachestop << " tp " << m_boundmax );
     m_cachestop=m_boundmax;
   }
   // keep track of time spent
   const float timeinc=cachetimer.RealTime();
   m_readtime+=timeinc;
-  if (m_log->level()<=MSG::DEBUG)
-    *m_log << "Cache retrieve done for " << m_foldername << " with " << 
+  ATH_MSG_DEBUG( "Cache retrieve done for " << m_foldername << " with " << 
       m_cachesince.size() << " objects stored in" << std::fixed <<
-      std::setw(8) << std::setprecision(2) << timeinc << " s" << endmsg;
+      std::setw(8) << std::setprecision(2) << timeinc << " s" );
   return true;
 }
 
@@ -541,12 +496,10 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
                                        cool::IDatabasePtr dbPtr,
                                        const ServiceHandle<IIOVSvc>& iovSvc) {
     
-  if (m_log->level()<=MSG::DEBUG)     
-    *m_log << MSG::DEBUG << "IOVDbFolder::recheck with DB for folder " << m_foldername
-           << " validitykey: " << vkey << endmsg;
+  ATH_MSG_DEBUG( "IOVDbFolder::recheck with DB for folder " << m_foldername
+           << " validitykey: " << vkey );
   if (!m_cachesince.size()) {
-    if (m_log->level()<=MSG::DEBUG)         
-      *m_log << MSG::DEBUG << "Cache empty ! returning ..." << endmsg;
+    ATH_MSG_DEBUG( "Cache empty ! returning ..." );
     return true;
   }
         
@@ -554,7 +507,6 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
   // access COOL inside try/catch in case of using stale connection
   unsigned int attempts     = 0;
   bool         retrievedone = false;
-  bool         checkChan    = false;
 
   while (attempts<2 && !retrievedone) {
     ++attempts;
@@ -571,26 +523,22 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
       } 
       else        m_nboundmin=m_nchan;
       
-      if (m_log->level()<=MSG::DEBUG) 
-        *m_log << MSG::DEBUG << "Expecting to see " << m_nboundmin << " channels" << endmsg;
+      ATH_MSG_DEBUG( "Expecting to see " << m_nboundmin << " channels" );
       m_nboundmax=m_nboundmin;
       // access COOL folder in case needed to resolve tag (even for CoraCool)
       cool::IFolderPtr folder=dbPtr->getFolder(m_foldername);
       // resolve the tag for MV folders if not already done so
-      if (m_multiversion && m_tag=="") { // NEEDED OR NOT?
+      if (m_multiversion && m_tag.empty()) { // NEEDED OR NOT?
         if (!resolveTag(folder,globalTag)) return false;
-        if (m_log->level()<=MSG::DEBUG)
-          *m_log << MSG::DEBUG << "resolveTag returns " << m_tag << endmsg;
+        ATH_MSG_DEBUG( "resolveTag returns " << m_tag );
       }
       
                 
                 
       int counter=0;
       if (m_foldertype==CoraCool) {
-        if (m_log->level()<=MSG::DEBUG) {
-          *m_log<< MSG::DEBUG<<"CoraCool folder cachestart:\t"<<m_cachestart<<" \t cachestop:"<< m_cachestop<<endmsg;
-          *m_log<< MSG::DEBUG<<"checking range:  "<<vkey+1<<" - "<<vkey+2<<endmsg;
-        }
+        ATH_MSG_DEBUG("CoraCool folder cachestart:\t"<<m_cachestart<<" \t cachestop:"<< m_cachestop);
+        ATH_MSG_DEBUG("checking range:  "<<vkey+1<<" - "<<vkey+2);
         // CoraCool retrieve initialise CoraCool connection
         CoraCoolDatabasePtr ccDbPtr   = m_conn->getCoraCoolDb();
         CoraCoolFolderPtr   ccfolder  = ccDbPtr->getFolder(m_foldername);
@@ -601,13 +549,10 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
         while (itr->hasNext()) {
           CoraCoolObjectPtr obj = itr->next();
                                         
-          // skip channels which are explicitly vetoed by range
-          if (checkChan && !isChanSelected(obj->channelId()))  continue;
                                         
-          if (m_log->level()<=MSG::DEBUG) 
-            *m_log << MSG::DEBUG<<"from DB \t chID: "<<obj->channelId()
+          ATH_MSG_DEBUG("from DB \t chID: "<<obj->channelId()
                    <<"\tobjstart:\t"<<obj->since()<<"\t objstop: \t"
-                   << obj->until() <<endmsg;
+                   << obj->until() );
                                         
           std::vector<cool::ValidityKey>::iterator st = m_cachesince.begin();
           std::vector<cool::ValidityKey>::iterator ut = m_cacheuntil.begin();
@@ -624,14 +569,10 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
               // obj time is larger than cache start (and less than cache stop)
               //   ==> update cache
               ++counter;
-              if (m_log->level()<=MSG::DEBUG) {
-                *m_log << MSG::DEBUG<<"special reload needed on THIS ONE !!!!!!!!!!!"<<endmsg;
-
+              ATH_MSG_DEBUG("special reload needed on THIS ONE !!!!!!!!!!!");
                 // just change existing IOVRange
-                *m_log << MSG::DEBUG<<"changing "<<(*ut)<<"  to "<<obj->since()-1<<endmsg;
-              }
+              ATH_MSG_DEBUG("changing "<<(*ut)<<"  to "<<obj->since()-1);
               (*ut)=obj->since()-1;
-
               specialCacheUpdate(obj, iovSvc); //  reset proxy, add to cache, addIOV 
               covered = 1;
               break; // can not be more than one
@@ -646,18 +587,16 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
             specialCacheUpdate(obj, iovSvc);
           }
         }
-        if (m_log->level()<=MSG::DEBUG) 
-          *m_log << MSG::DEBUG << "Need a special update for " << counter << " objects " << endmsg;
+        ATH_MSG_DEBUG( "Need a special update for " << counter << " objects " );
         itr->close();
         retrievedone=true;
     
 
       } else {
         
-        if (m_log->level()<=MSG::DEBUG) {
-          *m_log << MSG::DEBUG<<"not CoraCool type.   cachestart:"<<m_cachestart<<"  cachestop:"<< m_cachestop <<endmsg;
-          *m_log<< MSG::DEBUG<<"checking range:  "<<vkey+1<<" - "<<vkey+2<<endmsg;
-        }
+        ATH_MSG_DEBUG("not CoraCool type.   cachestart:"<<m_cachestart<<"  cachestop:"<< m_cachestop );
+        ATH_MSG_DEBUG("checking range:  "<<vkey+1<<" - "<<vkey+2);
+        
                 
         // this returns all the objects whose IOVRanges crosses this range . 
         cool::IObjectIteratorPtr itr=folder->browseObjects(vkey+1, vkey+2, m_chansel,m_tag);
@@ -665,12 +604,8 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
         while (itr->goToNext()) {
           const cool::IObject& ref=itr->currentRef();
                         
-          // skip channels which are explicitly vetoed by range
-          if (checkChan && !isChanSelected(ref.channelId())) continue;
         
-          if (m_log->level()<=MSG::DEBUG) 
-            *m_log << MSG::DEBUG<<"from DB -----> objstart:"<<ref.since()<<"  objstop:"
-                   << ref.until() <<" chID: "<<ref.channelId()<<endmsg;
+          ATH_MSG_DEBUG("from DB -----> objstart:"<<ref.since()<<"  objstop:"<< ref.until() <<" chID: "<<ref.channelId());
                         
           std::vector<cool::ValidityKey>::iterator st = m_cachesince.begin();
           std::vector<cool::ValidityKey>::iterator ut = m_cacheuntil.begin();
@@ -686,14 +621,10 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
             if ((*st) < ref.since() && ref.since() < (*ut)){
               // ref time is larger than cache start (and less than cache stop)
               //   ==> update cache
-              if (m_log->level()<=MSG::DEBUG) {
-                *m_log << MSG::DEBUG<<"special reload needed on this one !!!!!!!!!!!"<<endmsg;
+              ATH_MSG_DEBUG("special reload needed on this one !!!!!!!!!!!");
                 // just change existing IOVRange
-                *m_log << MSG::DEBUG<<"changing "<<(*ut)<<"  to "<<ref.since()-1<<endmsg;
-              }
-                            
-              (*ut)=ref.since()-1;
-                                        
+              ATH_MSG_DEBUG("changing "<<(*ut)<<"  to "<<ref.since()-1);
+              (*ut)=ref.since()-1;               
               ++counter;
               specialCacheUpdate(ref, iovSvc);
               covered=1;
@@ -712,8 +643,7 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
             specialCacheUpdate(ref, iovSvc);
           }
         }
-        if (m_log->level()<=MSG::DEBUG) 
-          *m_log << MSG::DEBUG << "Need a special update for " << counter << " objects " << endmsg; 
+        ATH_MSG_DEBUG( "Need a special update for " << counter << " objects " ); 
         itr->close();
         retrievedone=true;
       }      
@@ -722,18 +652,18 @@ bool IOVDbFolder::loadCacheIfDbChanged(const cool::ValidityKey vkey,
 
     }
     catch (std::exception& e) {
-      *m_log << MSG::WARNING << "COOL retrieve attempt " << attempts <<  " failed: " << e.what() << endmsg;
+      ATH_MSG_WARNING( "COOL retrieve attempt " << attempts <<  " failed: " << e.what() );
       try { // disconnect and reconnect
         m_conn->setInactive();
         dbPtr=m_conn->getCoolDb();
       }
       catch (std::exception& e) {
-        *m_log << MSG::WARNING << "Exception from disconnect/reconnect: " << e.what() << endmsg;
+        ATH_MSG_WARNING( "Exception from disconnect/reconnect: " << e.what() );
       }
     }
   }
 
-  *m_log << "Special cache check finished for folder " << m_foldername << endmsg;
+  ATH_MSG_INFO( "Special cache check finished for folder " << m_foldername );
   return true;
 }
 
@@ -744,8 +674,8 @@ void IOVDbFolder::specialCacheUpdate(CoraCoolObjectPtr obj,
   // time earlier than since.
   IOVRange range = makeRange(obj->since()-2, obj->since()-1);
   if (StatusCode::SUCCESS != iovSvc->setRange(clid(), key(), range, eventStore())) {
-    *m_log << MSG::ERROR << "IOVDbFolder::specialCacheUpdate - setRange failed for folder " 
-           << folderName() << endmsg;
+    ATH_MSG_ERROR( "IOVDbFolder::specialCacheUpdate - setRange failed for folder " 
+           << folderName() );
     return;
   }
     
@@ -755,19 +685,6 @@ void IOVDbFolder::specialCacheUpdate(CoraCoolObjectPtr obj,
   // store all the attributeLists in the buffer save pointer to start
   const unsigned int istart=m_cacheattr.size();
   for (CoraCoolObject::const_iterator pitr=obj->begin(); pitr!=obj->end();++pitr) {
-    // setup shared specification on first store
-    // if (m_cachespec==0) {  //never happens
-    //      m_cachespec=new coral::AttributeListSpecification;
-    //      m_varfields.clear();
-    //      m_fixedfields=0;
-    //      unsigned int ielm=0;
-    //      for (coral::AttributeList::const_iterator aitr=pitr->begin(); aitr!=pitr->end();++aitr,++ielm) {
-    //              const coral::AttributeSpecification& aspec=aitr->specification();
-    //              m_cachespec->extend(aspec.name(),aspec.type());
-    //              addType(aspec.typeName(),ielm);
-    //      }
-    //      *m_log << MSG::DEBUG << "Setup shared CoraCool AttributeListSpecifcation with " << m_cachespec->size() << " elements" << endmsg;
-    // }
     // use the shared specification in storing the payload
     m_cacheattr.push_back(coral::AttributeList(*m_cachespec,true));
     m_cacheattr.back().fastCopyData(*pitr);
@@ -784,8 +701,8 @@ void IOVDbFolder::specialCacheUpdate(const cool::IObject& ref,
   // time earlier than since.
   IOVRange range = makeRange(ref.since()-2, ref.since()-1);
   if (StatusCode::SUCCESS != iovSvc->setRange(clid(), key(), range, eventStore())) {
-    *m_log << MSG::ERROR << "IOVDbFolder::specialCacheUpdate - setRange failed for folder " 
-           << folderName() << endmsg;
+    ATH_MSG_ERROR( "IOVDbFolder::specialCacheUpdate - setRange failed for folder " 
+           << folderName() );
     return;
   }
 
@@ -793,27 +710,14 @@ void IOVDbFolder::specialCacheUpdate(const cool::IObject& ref,
   addIOVtoCache(ref.since(),ref.until());
   m_cachechan.push_back(ref.channelId());
   const coral::AttributeList& atrlist = ref.payload().attributeList();
-  // setup shared specification on first store
-  //     if (m_cachespec==0) { // never happens
-  // *m_log << MSG::DEBUG << "Setting up shared specs... " << m_key << endmsg;
-  //          m_cachespec=new coral::AttributeListSpecification;
-  //          m_varfields.clear();
-  //          m_fixedfields=0;
-  //          unsigned int ielm=0;
-  //          for (coral::AttributeList::const_iterator aitr=atrlist.begin();aitr!=atrlist.end();++aitr,++ielm) {
-  //                  const coral::AttributeSpecification& aspec=aitr->specification();
-  //                  m_cachespec->extend(aspec.name(),aspec.type());
-  //                  addType(aspec.typeName(),ielm);
-  //          }
-  //          *m_log << MSG::DEBUG << "Setup shared AttributeListSpecifcation with " << m_cachespec->size() << " elements" << endmsg;
-  //          }
+ 
   // use the shared specification in storing the payload
   m_cacheattr.push_back(coral::AttributeList(*m_cachespec,true));// maybe needs to be cleared before
-  if (m_log->level()<=MSG::DEBUG) {
+  /**if (m_msg.level()<=MSG::DEBUG) {
     std::ostringstream os;
     atrlist.toOutputStream(os);
-    *m_log << MSG::DEBUG << "AttributeList: " << os.str() << endmsg;
-  }
+    m_msg << MSG::DEBUG << "AttributeList: " << os.str() );
+  }**/
   m_cacheattr.back().fastCopyData(atrlist);
   countSize(atrlist);
 }
@@ -846,8 +750,7 @@ bool IOVDbFolder::getAddress(const cool::ValidityKey reftime,
     // get payload container, assuming it has the correct tag
     const IOVPayloadContainer* payload=m_metacon->payloadContainer();
     if (payload==0) {
-      *m_log << MSG::ERROR << "Could not find IOVPayloadContainer for folder "
-             << m_foldername << endmsg;
+      ATH_MSG_ERROR( "Could not find IOVPayloadContainer for folder "<< m_foldername );
       return false;
     }
     // get payload for current time, including case where nothing returned
@@ -858,29 +761,29 @@ bool IOVDbFolder::getAddress(const cool::ValidityKey reftime,
     bool newpptr=false; 
     const CondAttrListCollection* pptr;
     if (pitr==payload->end()) {
-      if (m_log->level()<=MSG::DEBUG) 
-        *m_log << MSG::DEBUG << "No IOVPayloadContainer for time " 
-               << ireftime << " so make empty CondAttrListCollection" << endmsg;
+      ATH_MSG_DEBUG( "No IOVPayloadContainer for time " 
+               << ireftime << " so make empty CondAttrListCollection");
       pptr=new CondAttrListCollection(!m_timestamp);
       newpptr=true;
     } else {
       pptr=*pitr;
     }
+    FolderType fType=IOVDbNamespace::determineFolderType(pptr);
     m_nobjread+=pptr->size();
     // check for single magic channel - then need an AttributeList or PoolRef
-    if (pptr->size()==1 && pptr->begin()->first==0xFFFF) {
-      // check if this is a poolref
+    if ((fType==PoolRef) or (fType==AttrList)) {
       const coral::AttributeList& payload1=pptr->begin()->second;
-      const coral::AttributeSpecification& spec=payload1[0].specification();
-      if (spec.name()=="PoolRef" && spec.typeName()=="string") {
+      if (fType==PoolRef) {
         // single channel with PoolRef
         strAddress=payload1[0].data<std::string>();
         poolPayloadReq=true;
+        ATH_MSG_WARNING( "Folder type set to PoolRef");
         m_foldertype=PoolRef;
       } else {
         // create an AthenaAttributeList for this data
         attrList=new AthenaAttributeList(payload1);
         strAddress="POOLContainer_AthenaAttributeList][CLID=x";
+        ATH_MSG_WARNING( "Folder type set to AttrList");
         m_foldertype=AttrList;
       }
       range=(pptr->iov_begin())->second;
@@ -889,11 +792,10 @@ bool IOVDbFolder::getAddress(const cool::ValidityKey reftime,
       // this can only be done if the collection is non-empty
       // otherwise we assume it is a CondAttrListCollection
       m_foldertype=AttrListColl;
-      if (pptr->size()>0) {
-        const coral::AttributeList& payload1=pptr->begin()->second;
-        const coral::AttributeSpecification& spec=payload1[0].specification();
-        if (spec.name()=="PoolRef" && spec.typeName()=="string") {
+      if (pptr->size()>0) {     
+        if (fType==PoolRefColl) {
           m_foldertype=PoolRefColl;
+          ATH_MSG_WARNING( "Folder type set to PoolRefColl");
           poolPayloadReq=true;
         }
       }
@@ -904,9 +806,8 @@ bool IOVDbFolder::getAddress(const cool::ValidityKey reftime,
       // release the pointer if we created a new CondAttrListCollection object
       if (newpptr) delete pptr;
     }
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << "Read file metadata for folder " << m_foldername 
-             << " foldertype is " << m_foldertype << endmsg;
+    ATH_MSG_DEBUG( "Read file metadata for folder " << m_foldername 
+             << " foldertype is " << m_foldertype );
   } else {
     // COOL/CoraCool data to be read from cache
     // for AttrListColl or PoolRefColl, need a CondAttrListCollection ready
@@ -949,14 +850,11 @@ bool IOVDbFolder::getAddress(const cool::ValidityKey reftime,
                                 m_cachechan[ic],m_cacheattr,
                                 m_cacheccstart[ic],m_cacheccend[ic]);
           if (m_writemeta) {
-            *m_log << MSG::ERROR << 
-              "Writing of CoraCool folders to file metadata not implemented" 
-                   << endmsg;
+            ATH_MSG_ERROR( "Writing of CoraCool folders to file metadata not implemented");
             return false;
           }
         } else {
-          *m_log << MSG::ERROR << "Unhandled folder type " << m_foldertype
-                 << endmsg;
+          ATH_MSG_ERROR( "Unhandled folder type " << m_foldertype);
           return false;
         }
       } else if (m_cacheuntil[ic]<=reftime && m_cacheuntil[ic]>naystart) {
@@ -984,30 +882,28 @@ bool IOVDbFolder::getAddress(const cool::ValidityKey reftime,
     } else if (m_foldertype==AttrList || m_foldertype==PoolRef) {
       // single object retrieve - should have exactly one object
       if (nobj==0) {
-        *m_log << MSG::ERROR << 
-          "COOL object not found in single-channel retrieve, folder " 
-               << m_foldername << " currentTime " << reftime << endmsg;
+        ATH_MSG_ERROR("COOL object not found in single-channel retrieve, folder " 
+               << m_foldername << " currentTime " << reftime );
         return false;
       } else if (nobj>1) {
-        *m_log << MSG::ERROR << nobj << 
+        ATH_MSG_ERROR( nobj << 
           " valid objects found for single-channel retrieve, folder " << 
-          m_foldername << " currentTime " << reftime << endmsg;
+          m_foldername << " currentTime " << reftime );
         return false;
       }
     }
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << "Retrieved object: folder " << m_foldername 
+    //was debug
+    ATH_MSG_DEBUG( "Retrieved object: folder " << m_foldername 
              <<  " at IOV " << reftime << " channels " << nobj << " has range " 
-             << range << endmsg;
+             << range );
     // shrink range so it does not extend into 'gap' channels or outside cache
     IOVTime tnaystart=makeTime(naystart);
     IOVTime tnaystop=makeTime(naystop);
     IOVTime rstart=range.start();
     IOVTime rstop=range.stop();
     if (tnaystart > rstart || rstop > tnaystop) {
-      if (m_log->level()<=MSG::DEBUG) 
-        *m_log << MSG::DEBUG << "Shrink IOV range from [" << rstart << ":" <<
-          rstop << "] to [" << tnaystart << ":" << tnaystop << "]" << endmsg;
+      ATH_MSG_DEBUG( "Shrink IOV range from [" << rstart << ":" <<
+          rstop << "] to [" << tnaystart << ":" << tnaystop << "]" );
       if (tnaystart > rstart) rstart=tnaystart;
       if (tnaystop  < rstop)  rstop=tnaystop;
       range=IOVRange(rstart,rstop);
@@ -1029,14 +925,14 @@ bool IOVDbFolder::getAddress(const cool::ValidityKey reftime,
   // turn the data into an IOpaqueAddress
   strAddress=m_addrheader+strAddress;
   if (StatusCode::SUCCESS!=persSvc->createAddress(0,0,strAddress,address)) {
-    *m_log << MSG::ERROR << "Could not get IOpaqueAddress from string address "
-           << strAddress << endmsg;
+    ATH_MSG_ERROR( "Could not get IOpaqueAddress from string address "
+           << strAddress );
     return false;
   }
   GenericAddress* gAddr=dynamic_cast<GenericAddress*>(address);
   if (!gAddr) {
-    *m_log << MSG::ERROR << "Could not cast IOpaqueAddress to GenericAddress" 
-           << endmsg;
+    ATH_MSG_ERROR( "Could not cast IOpaqueAddress to GenericAddress" 
+           );
     return false;
   }
   // create a new GenericAddress to set pool context
@@ -1071,31 +967,18 @@ bool IOVDbFolder::getAddress(const cool::ValidityKey reftime,
 
 
 void IOVDbFolder::summary() {
+  const std::string & folderTypeName=IOVDbNamespace::folderTypeName(m_foldertype);
   // summarise the read statistics for this folder
-  *m_log << MSG::INFO <<  "Folder " << m_foldername << " (";
-  if (m_foldertype==AttrList) {
-    *m_log << "AttrList";
-  } else if (m_foldertype==AttrListColl) {
-    *m_log << "AttrListColl";
-  } else if (m_foldertype==PoolRef) {
-    *m_log << "PoolRef";
-  } else if (m_foldertype==PoolRefColl) {
-    *m_log << "PoolColl";
-  } else if (m_foldertype==CoraCool) {
-    *m_log << "CoraCool";
-  } else if (m_foldertype==CoolVector) {
-    *m_log << "CoolVector";
-  } else {
-    *m_log << "Unknown";
-  }
-  *m_log << ") db-read " << m_ndbread << "/" << 
-    m_ncacheread << " objs/chan/bytes " << m_nobjread << "/" << 
-    m_nchan << "/" << m_nbytesread << " (( " << std::fixed << std::setw(8)
-         << std::setprecision(2) << m_readtime << " ))s" << endmsg;
+  ATH_MSG_INFO(  "Folder " << m_foldername << " ("<<folderTypeName
+	    << ") db-read " << m_ndbread << "/" <<
+	    m_ncacheread << " objs/chan/bytes " << m_nobjread << "/" <<
+	    m_nchan << "/" << m_nbytesread << " (( " << std::fixed << std::setw(8)
+	         << std::setprecision(2) << m_readtime << " ))s" );
+	
   // print WARNING if data for this fodler was never read from Storegate
   if (m_ncacheread==0 && m_ndbread>0) {
-    *m_log << MSG::WARNING << "Folder " << m_foldername << 
-      " is requested but no data retrieved" << endmsg;
+    ATH_MSG_WARNING( "Folder " << m_foldername << 
+      " is requested but no data retrieved" );
   }
 }
 
@@ -1109,9 +992,7 @@ IOVDbFolder::preLoadFolder(StoreGateSvc* detStore,
   // as detector store does not exist yet in IOVDbSvc initialisation
   // and sets up cache length, taking into account optional overrides
   // returns null pointer in case of problem
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "preLoadFolder for folder " << m_foldername 
-           << endmsg;
+  ATH_MSG_DEBUG( "preLoadFolder for folder " << m_foldername);
   p_detStore=detStore;
   std::string folderdesc;
   cool::IDatabasePtr dbPtr;
@@ -1121,49 +1002,44 @@ IOVDbFolder::preLoadFolder(StoreGateSvc* detStore,
     // get COOL database - will wake up connection on first access
     dbPtr=m_conn->getCoolDb();
     if (dbPtr.get()==0) {
-      *m_log << MSG::FATAL << "Conditions database connection " 
-             << m_conn->name() << " cannot be opened - STOP" << endmsg;
+      ATH_MSG_FATAL( "Conditions database connection " << m_conn->name() << " cannot be opened - STOP" );
       return 0;
     }
     // get folder and read information
     if (!dbPtr->existsFolder(m_foldername)) {
-      *m_log << MSG::FATAL << "Folder " << m_foldername << " does not exist" 
-             << endmsg;
+      ATH_MSG_FATAL( "Folder " << m_foldername << " does not exist" );
       return 0;
     }
     fldPtr=dbPtr->getFolder(m_foldername);
     // get versiontype of folder
-    m_multiversion=(fldPtr->versioningMode()==
-                    cool::FolderVersioning::MULTI_VERSION);
+    m_multiversion=(fldPtr->versioningMode()==cool::FolderVersioning::MULTI_VERSION);
     // read and process description string
     folderdesc=fldPtr->description();
   } else {
     // folder from meta-data
     folderdesc=m_metacon->folderDescription();
   }
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "Folder description " << folderdesc << endmsg;
+  ATH_MSG_DEBUG( "Folder description " << folderdesc);
 
   // register folder with meta-data tool if writing metadata
   if (m_writemeta) {
     if (StatusCode::SUCCESS!=p_metaDataTool->registerFolder(m_foldername,
                                                             folderdesc)) {
-      *m_log << MSG::ERROR << "Failed to register folder " << m_foldername
-             << " for meta-data write" << endmsg;
+      ATH_MSG_ERROR( "Failed to register folder " << m_foldername
+             << " for meta-data write" );
       return 0;
     }
   }
 
   // parse the description string
-  IOVDbParser folderpar(folderdesc,m_log);
+  IOVDbParser folderpar(folderdesc,m_msg.get());
   // check for timeStamp indicating folder is timestamp indexed
   std::string buf;
   m_timestamp=(folderpar.getKey("timeStamp","",buf) && buf=="time");
   // check for key, giving a different key to the foldername
   if (folderpar.getKey("key","",buf) && !m_jokey) {
-    if (m_log->level()<=MSG::DEBUG)
-      *m_log << MSG::DEBUG << "Key for folder " << m_foldername << " set to "
-             << buf << " from description string" << endmsg;
+    ATH_MSG_DEBUG( "Key for folder " << m_foldername << " set to "
+             << buf << " from description string" );
     m_key=buf;
   }
   // check for 'cache' but only if not already found in joboptions
@@ -1179,53 +1055,33 @@ IOVDbFolder::preLoadFolder(StoreGateSvc* detStore,
   bool gotCLID=false;
   // get addressHeader
   if (folderpar.getKey("addrHeader","",m_addrheader)) {
-    const std::size_t svcType = m_addrheader.find("service_type=\"71\"");
-    if (svcType != std::string::npos) {
-      m_addrheader.replace(svcType, 17, "service_type=\"256\"");
-    }
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << "Decode addrHeader " << m_addrheader << endmsg;
-    IOVDbParser addrH(m_addrheader,m_log);
+    IOVDbNamespace::replaceServiceType71(m_addrheader);
+    ATH_MSG_DEBUG( "Decode addrHeader " << m_addrheader);
+    IOVDbParser addrH(m_addrheader,m_msg.get());
     std::string addr2;
     // parse addrHeader XML of form
     // <addrHeader><address_header service_type="256" clid="12345" /></addrHeader>
     if (addrH.getKey("address_header","",addr2)) {
       // look for 'clid', then number between quotes afterwards
-      std::string::size_type iofs=addr2.find("clid");
-      if (iofs!=std::string::npos) {
-        std::string::size_type iofs1=addr2.find("\"",iofs+4);
-        if (iofs1!=std::string::npos) {
-          std::string::size_type iofs2=addr2.find("\"",iofs1+1);
-          if (iofs2!=std::string::npos) {
-            std::istringstream is(addr2.substr(iofs1+1,iofs2-iofs1-1));
-            is >> m_clid;
-            if (m_log->level()<=MSG::DEBUG) 
-              *m_log << MSG::DEBUG << "Got CLID " << m_clid << " from " 
-                     << addr2 << endmsg;
-            gotCLID=true;
-          }
-        }
-      }
+      m_clid = IOVDbNamespace::parseClid(addr2);
+      ATH_MSG_DEBUG( "Got CLID " << m_clid << " from " << addr2 );
+      gotCLID=(m_clid>0);
     }
   }
   // decode the typeName
   if (!folderpar.getKey("typeName","",m_typename)) {
-    *m_log << MSG::ERROR << "Primary type name is empty" << endmsg;
+    ATH_MSG_ERROR( "Primary type name is empty" );
     return 0;
   }
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "Got folder typename " << m_typename << endmsg;
+  ATH_MSG_DEBUG( "Got folder typename " << m_typename );
   if (!gotCLID)
     if (StatusCode::SUCCESS==p_clidSvc->getIDOfTypeName(m_typename,m_clid)) 
       gotCLID=true;
   if (!gotCLID) {
-    *m_log << MSG::ERROR << "Could not get clid for typeName: " << 
-      m_typename << endmsg;
+    ATH_MSG_ERROR("Could not get clid for typeName: " << m_typename);
     return 0;
   }
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "Got folder typename " << m_typename << 
-      " with CLID " << m_clid << endmsg;
+  ATH_MSG_DEBUG( "Got folder typename " << m_typename <<  " with CLID " << m_clid );
 
   // setup channel list and folder type
   if (m_metacon==0) {
@@ -1241,15 +1097,13 @@ IOVDbFolder::preLoadFolder(StoreGateSvc* detStore,
         m_channames.push_back(chitr->second);
       }
       m_nchan=m_channums.size();
-      if (m_log->level()<=MSG::DEBUG)
-        *m_log << MSG::DEBUG << "Retrieving list of channel numbers/names: got "
-               << m_nchan << " channels " << endmsg;
+      ATH_MSG_DEBUG( "Retrieving list of channel numbers/names: got "
+               << m_nchan << " channels " );
     } else {
       m_channums=fldPtr->listChannels();
       m_nchan=m_channums.size();
-      if (m_log->level()<=MSG::DEBUG) 
-        *m_log << MSG::DEBUG << "Retrieving list of channel numbers only: got "
-               << m_nchan << " channels " << endmsg;
+      ATH_MSG_DEBUG( "Retrieving list of channel numbers only: got "
+               << m_nchan << " channels " );
     }
 
     // set folder type 
@@ -1276,9 +1130,7 @@ IOVDbFolder::preLoadFolder(StoreGateSvc* detStore,
         }
       }
     }
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << "Folder identified as type " << m_foldertype << 
-        endmsg;
+    ATH_MSG_DEBUG( "Folder identified as type " << m_foldertype );
   }
   // note that for folders read from metadata, folder type identification
   // is deferred until getAddress when first data is read
@@ -1294,39 +1146,19 @@ IOVDbFolder::preLoadFolder(StoreGateSvc* detStore,
   // process symlinks, if any
   if (folderpar.getKey("symlinks","",buf)) {
     // symlinks specified as <symlink>A:B:C</symlink> i.e. colon-sep list
-    std::string linkname;
-    std::string::size_type idx;
-    do {
-      // Type names may be qualified C++ names including a scope: SCOPE::NAME.
-      // So ignore double colons when splitting the symlink list.
-      idx = 0;
-      while (true) {
-        idx=buf.find(":", idx);
-        if (idx == std::string::npos || buf[idx+1] != ':') break;
-        idx += 2;
-      }
-
-      if (idx!=std::string::npos) {
-        linkname=buf.substr(0,idx);
-        buf=buf.substr(1+idx,buf.size());
-      } else {
-        linkname=buf;
-      }
-      linkname=spaceStrip(linkname);
-      if (linkname!="") {
+    const auto linknameVector=IOVDbNamespace::parseLinkNames(buf);
+    for (const auto & linkname:linknameVector){
+      if (not linkname.empty()) {
         CLID sclid;
         if (StatusCode::SUCCESS==p_clidSvc->getIDOfTypeName(linkname,sclid)) {
           tad->setTransientID(sclid);
-          if (m_log->level()<=MSG::DEBUG) 
-            *m_log << MSG::DEBUG << "Setup symlink " << linkname << " CLID " <<
-              sclid << " for folder " << m_foldername << endmsg;
+          ATH_MSG_DEBUG( "Setup symlink " << linkname << " CLID " <<sclid << " for folder " << m_foldername );
         } else {
-          *m_log << MSG::ERROR << "Could not get clid for symlink: "
-                 << linkname << endmsg;
+          ATH_MSG_ERROR( "Could not get clid for symlink: "<< linkname );
           return 0;
         }
       }
-    } while (idx!=std::string::npos);
+   }
   }
 
   // setup cache length
@@ -1340,9 +1172,7 @@ IOVDbFolder::preLoadFolder(StoreGateSvc* detStore,
       if (m_cachepar!="") clen=atoi(m_cachepar.c_str());
     }
     m_cachelength=clen*1000000000LL;
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << "Cache length set to " << clen << " seconds" << 
-        endmsg;
+    ATH_MSG_DEBUG( "Cache length set to " << clen << " seconds" );
   } else {
     // for run/event, cache parameter sets length in LB
     // default value is 1 whole run (-1 to avoid getting the next run)
@@ -1353,9 +1183,8 @@ IOVDbFolder::preLoadFolder(StoreGateSvc* detStore,
     } else {
       if (m_cachepar!="") m_cachelength=atoi(m_cachepar.c_str());
     }
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << "Cache length set to " << (m_cachelength >> 32) <<
-        " runs " << (m_cachelength & 0xFFFFFFFF) << " lumiblocks" << endmsg;
+    ATH_MSG_DEBUG( "Cache length set to " << (m_cachelength >> 32) <<
+        " runs " << (m_cachelength & 0xFFFFFFFF) << " lumiblocks" );
   }
   return tad;
 }
@@ -1415,8 +1244,7 @@ bool IOVDbFolder::resolveTag(cool::IFolderPtr fptr,
   if (tag=="HEAD") return true;
   if (tag=="") tag=globalTag;
   if (tag=="") {
-    *m_log << MSG::ERROR << 
-      "No IOVDbSvc.GlobalTag specified on job options or input file" << endmsg;
+    ATH_MSG_ERROR( "No IOVDbSvc.GlobalTag specified on job options or input file" );
     return false;
   }
   // check for magic tags
@@ -1428,14 +1256,13 @@ bool IOVDbFolder::resolveTag(cool::IFolderPtr fptr,
   const std::vector<std::string>& taglist=fptr->listTags();
   if (find(taglist.begin(),taglist.end(),tag)!=taglist.end()) {
     // tag exists directly in folder
-    if (m_log->level()<=MSG::DEBUG) *m_log << MSG::DEBUG << "Using tag "
-                                           << tag << " for folder " << m_foldername << endmsg;
+    ATH_MSG_DEBUG( "Using tag "<< tag << " for folder " << m_foldername );
   } else {
     // tag maybe an HVS tag 
     try {
       std::string restag=fptr->resolveTag(tag);
-      *m_log << MSG::INFO << "HVS tag " << tag << " resolved to "
-             << restag << " for folder " << m_foldername << endmsg;
+      ATH_MSG_INFO( "HVS tag " << tag << " resolved to "
+             << restag << " for folder " << m_foldername );
       // HVS tag may itself be magic
       if (restag.substr(0,7)=="TagInfo" && 
           restag.find('/')!=std::string::npos) {
@@ -1444,8 +1271,7 @@ bool IOVDbFolder::resolveTag(cool::IFolderPtr fptr,
       tag=restag;
     }
     catch (cool::Exception& e) {
-      *m_log << MSG::ERROR << "Tag " << tag << 
-        " cannot be resolved for folder " << m_foldername << endmsg;
+      ATH_MSG_ERROR( "Tag " << tag <<" cannot be resolved for folder " << m_foldername );
       return false;
     }
   }
@@ -1454,14 +1280,12 @@ bool IOVDbFolder::resolveTag(cool::IFolderPtr fptr,
   if (m_checklock) {
     try {
       if (fptr->tagLockStatus(tag)!=cool::HvsTagLock::LOCKED) {
-        *m_log << MSG::ERROR << "Tag " << tag << 
-          " is not locked and IOVDbSvc.CheckLock is set" << endmsg;
+        ATH_MSG_ERROR("Tag " << tag <<" is not locked and IOVDbSvc.CheckLock is set" );
         return false;
       }
     }
     catch (cool::Exception& e) {
-      *m_log << MSG::ERROR << "Could not check tag lock status for " << tag 
-             << endmsg;
+      ATH_MSG_ERROR( "Could not check tag lock status for " << tag );
       return false;
     }
   }
@@ -1477,26 +1301,17 @@ bool IOVDbFolder::magicTag(std::string& tag) {
   // return true for successful resolution
   const std::string inputtag=tag;
   tag="";
-  std::string prefix="";
-  // find the / after the TagInfo{Major|Minor}
-  std::string::size_type ptr1=inputtag.find('/');
-  if (ptr1==std::string::npos) return false;
-  std::string target=inputtag.substr(ptr1+1);
-  // check for TagInfoMajor or TagInfoMinor - if so, will need to strip
-  // characters from the end of the looked up tag
   std::string::size_type rstrip=0;
-  if (inputtag.substr(7,5)=="Major") {
-    rstrip=6;
-  } else if (inputtag.substr(7,5)=="Minor") {
-    rstrip=3;
-  }
-  std::string::size_type ptr=target.find("/");
-  if (ptr!=std::string::npos) {
-    prefix=target.substr(0,ptr);
-    target=target.substr(ptr+1);
-  }
-  if (m_log->level()<=MSG::DEBUG) *m_log << MSG::DEBUG << 
-                                    "In magicTag for tag name: " << target << " prefix " << prefix << endmsg;
+  enum ResultIndices{WHOLETAG, MAJMIN, PATH1, PATH2, SIZEWITHPREFIX};
+  auto results=IOVDbNamespace::parseMagicTag(inputtag);
+  if (results.empty())   return false;
+  //number of characters to strip from tag end
+  rstrip = (results[MAJMIN] == "Major")?6:3;
+  //revisit with C++17 in mind
+  const auto & resultPair = IOVDbNamespace::tag2PrefixTarget(results);
+  const std::string & prefix=resultPair.first;
+  const std::string & target=resultPair.second;
+  ATH_MSG_DEBUG("In magicTag for tag name: " << target << " prefix " << prefix );
 
   // try to get TagInfo object
   const TagInfo* tagInfo=0;
@@ -1507,27 +1322,23 @@ bool IOVDbFolder::magicTag(std::string& tag) {
   }
   // if nothing found, try to get GeoAtlas directly from GeoModelSvc
   if (tag=="" && target=="GeoAtlas") {
-    if (m_log->level()<=MSG::DEBUG)  *m_log << MSG::DEBUG << 
-                                       "Attempt to get GeoAtlas tag directly from GeoModelSvc" << endmsg;
+    ATH_MSG_DEBUG( "Attempt to get GeoAtlas tag directly from GeoModelSvc" );
     IGeoModelSvc* geomodel=0;
     ISvcLocator* svcLocator=Gaudi::svcLocator();
     if (svcLocator==0 || 
         StatusCode::SUCCESS!=svcLocator->service("GeoModelSvc",geomodel)) {
-      *m_log << MSG::ERROR << "Cannot get GeoModelSvc" << endmsg;
+      ATH_MSG_ERROR( "Cannot get GeoModelSvc" );
     } else { 
       tag=prefix+geomodel->atlasVersion();
-      *m_log << MSG::INFO << "Resolved tag " << target << " to " << 
-        tag << " directly from GeoModel" << endmsg;
+      ATH_MSG_DEBUG( "Resolved tag " << target << " to " << tag << " directly from GeoModel" );
     }
   }
   if (tag!="") {
     // check if characters need to be stripped from end of tag
     if (rstrip>0 && tag.size()>rstrip) tag=tag.substr(0,tag.size()-rstrip);
-    *m_log << MSG::INFO << "Resolved TagInfo tag " << target 
-           << " to value " << tag << endmsg;
+    ATH_MSG_DEBUG( "Resolved TagInfo tag " << target  << " to value " << tag );
   } else {
-    *m_log << MSG::ERROR << "Could not resolve TagInfo tag " << target 
-           << endmsg;
+    ATH_MSG_ERROR( "Could not resolve TagInfo tag " << target );
   }
   return (tag!="");
 }
@@ -1548,13 +1359,10 @@ bool IOVDbFolder::addMetaAttrListColl(const CondAttrListCollection* coll) {
   // make a new CondAttrListCollection for the payload
   CondAttrListCollection* flmdColl=new CondAttrListCollection(*coll);
   if (StatusCode::SUCCESS!=p_metaDataTool->addPayload(m_foldername,flmdColl)) {
-    *m_log << MSG::ERROR << 
-      "addMetaAttrList: Failed to write metadata for folder " << m_foldername
-           << endmsg;
+    ATH_MSG_ERROR( "addMetaAttrList: Failed to write metadata for folder " << m_foldername);
     return false;
   } else {
-    if (m_log->level()<=MSG::DEBUG) *m_log << MSG::DEBUG << 
-                                      "addMetaAttrList: write metadata for folder " << m_foldername << endmsg;
+    ATH_MSG_DEBUG( "addMetaAttrList: write metadata for folder " << m_foldername );
     return true;
   }
 }
@@ -1574,9 +1382,9 @@ void IOVDbFolder::addType(const std::string& type,const unsigned int ielm)
   } else if (type=="blob") {
     m_varfields.push_back(VarSizePair(2,ielm));
   } else {
-    *m_log << MSG::WARNING << "addType: unknown type " << type << 
+    ATH_MSG_WARNING( "addType: unknown type " << type << 
       " in folder " << m_foldername << 
-      " will not be counted for bytes-read statistics" << endmsg;
+      " will not be counted for bytes-read statistics" );
   }
 }
 
@@ -1591,10 +1399,8 @@ void IOVDbFolder::setSharedSpec(const coral::AttributeList& atrlist) {
     m_cachespec->extend(aspec.name(),aspec.type());
     addType(aspec.typeName(),ielm);
   }
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG 
-           << "Setup shared AttributeListSpecifcation with " << 
-      m_cachespec->size() << " elements" << endmsg;
+  ATH_MSG_DEBUG( "Setup shared AttributeListSpecifcation with " << 
+      m_cachespec->size() << " elements" );
 }
 
 void IOVDbFolder::countSize(const coral::AttributeList& atrlist) {
@@ -1614,32 +1420,7 @@ void IOVDbFolder::countSize(const coral::AttributeList& atrlist) {
   }
 }
 
-bool IOVDbFolder::isChanSelected(const cool::ChannelId chan) {
-  // simple check of channel ranges
-  bool sel=false;
-  for (std::vector<ChanRange>::const_iterator itr=m_chanrange.begin();
-       itr!=m_chanrange.end(); ++itr) {
-    if (chan>=itr->first && chan<=itr->second) {
-      sel=true;
-      break;
-    }
-  }
-  return sel;
-}
-
-std::string IOVDbFolder::spaceStrip(const std::string& input) const {
-  // return the input string stripped of leading/trailing spaces
-  std::string::size_type idx1=input.find_first_not_of(" ");
-  std::string::size_type idx2=input.find_last_not_of(" ");
-  if (idx1==std::string::npos || idx2==std::string::npos) {
-    return "";
-  } else {
-    return input.substr(idx1,1+idx2-idx1);
-  }
-}
-
-void IOVDbFolder::addIOVtoCache(cool::ValidityKey since,
-                                cool::ValidityKey until) {
+void IOVDbFolder::addIOVtoCache(cool::ValidityKey since,cool::ValidityKey until) {
   // add IOV to the cache, and check for IOVs crossing cache boundaries
   // indicating missing channels
   m_cachesince.push_back(since);
@@ -1656,16 +1437,15 @@ void IOVDbFolder::addIOVtoCache(cool::ValidityKey since,
 }
 
 void IOVDbFolder::printCache(){
-  if (m_log->level()<=MSG::DEBUG) {
-    *m_log<<MSG::DEBUG<<"folder cache printout -------------------"<<endmsg;
-    *m_log<<MSG::DEBUG<<"length: "<<m_cachelength<<"\tstart: "<<m_cachestart<<"\tstop: "<<m_cachestop<<endmsg;
-    *m_log<<MSG::DEBUG<<"current range: "<<m_currange<<endmsg;
+    ATH_MSG_DEBUG("folder cache printout -------------------");
+    ATH_MSG_DEBUG("length: "<<m_cachelength<<"\tstart: "<<m_cachestart<<"\tstop: "<<m_cachestop);
+    ATH_MSG_DEBUG("current range: "<<m_currange);
     std::vector<cool::ValidityKey>::iterator i= m_cachesince.begin();
     std::vector<cool::ValidityKey>::iterator o= m_cacheuntil.begin();
     std::vector<cool::ChannelId>::iterator      ci= m_cachechan.begin();
     for (;i!=m_cachesince.end();++i,++o,++ci){
-      *m_log<<MSG::DEBUG<<"channelID:\t"<<(*ci)<<"\t since: "<<(*i)<<"\t until: "<<(*o)<<endmsg;
+      ATH_MSG_DEBUG("channelID:\t"<<(*ci)<<"\t since: "<<(*i)<<"\t until: "<<(*o));
     }
-    *m_log<<MSG::DEBUG<<"folder cache printout -------------------"<<endmsg;
-  }
+    ATH_MSG_DEBUG("folder cache printout -------------------");
+  
 }
diff --git a/Database/IOVDbSvc/src/IOVDbFolder.h b/Database/IOVDbSvc/src/IOVDbFolder.h
index f423451f389c91616256952a98faeec086fe140b..229a23f6479107e6079df000957e83c065f6abed 100644
--- a/Database/IOVDbSvc/src/IOVDbFolder.h
+++ b/Database/IOVDbSvc/src/IOVDbFolder.h
@@ -8,7 +8,9 @@
 #ifndef IOVDBSVC_IOVDBFOLDER_H
 #define IOVDBSVC_IOVDBFOLDER_H
 
-#include<string>
+#include <string>
+#include "AthenaKernel/MsgStreamMember.h"
+#include "AthenaBaseComps/AthMsgStreamMacros.h"
 #include "AthenaKernel/IClassIDSvc.h"
 #include "AthenaKernel/IOVTime.h"
 #include "AthenaKernel/IOVRange.h"
@@ -22,6 +24,7 @@
 #include "CoraCool/CoraCoolObjectIter.h"
 #include "CoraCool/CoraCoolObject.h"
 #include <memory>
+#include "FolderTypes.h"
 
 class MsgStream;
 class IOVDbConn;
@@ -34,18 +37,10 @@ class CondAttrListCollection;
 
 class IOVDbFolder {
 public:
-  IOVDbFolder(IOVDbConn* conn,const IOVDbParser& folderprop, MsgStream* msg,
+  IOVDbFolder(IOVDbConn* conn,const IOVDbParser& folderprop, MsgStream & /*msg*/,
               IClassIDSvc* clidsvc,const bool checkglock);
   ~IOVDbFolder();
-  // enum for folder types
-  enum FolderType {
-    AttrList=0,
-    AttrListColl,
-    PoolRef,
-    PoolRefColl,
-    CoraCool,
-    CoolVector
-  };
+  
 
   // access methods to various internal information
   const std::string& folderName() const;
@@ -56,7 +51,7 @@ public:
   bool tagOverride() const;
   bool retrieved() const;
   bool noOverride() const;
-  FolderType folderType() const;
+  IOVDbNamespace::FolderType folderType() const;
   bool readMeta() const;
   bool writeMeta() const;
   // read from meta data only, otherwise ignore folder
@@ -151,10 +146,8 @@ private:
   void setSharedSpec(const coral::AttributeList& atrlist);
   // calculate bytesize of given attributeList, using cached typeinfo
   void countSize(const coral::AttributeList& atrlist);
-  // return if channel is selected, compensating for COOL channel seln bug
-  bool isChanSelected(const cool::ChannelId chan);
-  // strip leading/trailing spaces from given string
-  std::string spaceStrip(const std::string& input) const;
+  
+  
   // add this IOV to cache, including channel counting if over edge of cache
   void addIOVtoCache(cool::ValidityKey since, cool::ValidityKey until);
 
@@ -164,8 +157,13 @@ private:
 
   void specialCacheUpdate(const cool::IObject& obj,
                           const ServiceHandle<IIOVSvc>& iovSvc);
+  //override IOV with run, lumi specified
+  void overrideWithRunLumi(const unsigned long long run, const unsigned long long lb=0);
 
-  MsgStream*           m_log;
+  //override IOV with timestamp sepcified
+  void overrideWithTimestamp(const unsigned long long timestamp);
+
+  
   StoreGateSvc*        p_detStore;     // pointer to detector store
   IClassIDSvc*         p_clidSvc;      // pointer to CLID service
   IIOVDbMetaDataTool*  p_metaDataTool; // pointer to metadata tool (writing)
@@ -186,7 +184,7 @@ private:
   bool m_autocache;    // indicates if cache length was automatically set
   bool m_checklock;    // indicates if global tags should be checked locked
   cool::ValidityKey m_iovoverride; // validity key to use
-  FolderType        m_foldertype; // type of data in folder (enum)
+  IOVDbNamespace::FolderType        m_foldertype; // type of data in folder (enum)
   const IOVMetaDataContainer* m_metacon; // metadata container (=0 if not FLMD)
 
   cool::ValidityKey m_cachelength; // length of cache
@@ -239,6 +237,23 @@ private:
   std::vector<coral::AttributeList> m_cacheattr;
   std::vector<unsigned int> m_cacheccstart;
   std::vector<unsigned int> m_cacheccend;
+  
+  protected:
+   /// Log a message using the Athena controlled logging system
+          MsgStream&
+          msg(MSG::Level lvl) const {
+            return m_msg.get() << lvl;
+          }
+       
+          /// Check whether the logging system is active at the provided verbosity level
+          bool
+          msgLvl(MSG::Level lvl) {
+            return m_msg.get().level() <= lvl;
+          }
+       
+          /// Private message stream member
+          mutable Athena::MsgStreamMember m_msg;
+  
 };
 
 inline const std::string& IOVDbFolder::folderName() const {return m_foldername;}
@@ -256,7 +271,7 @@ inline bool IOVDbFolder::noOverride() const { return m_notagoverride; }
 
 inline bool IOVDbFolder::retrieved() const { return m_retrieved; }
 
-inline IOVDbFolder::FolderType IOVDbFolder::folderType() const 
+inline IOVDbNamespace::FolderType IOVDbFolder::folderType() const 
 {return m_foldertype;}
 
 inline bool IOVDbFolder::readMeta() const { return (m_metacon!=0); }
diff --git a/Database/IOVDbSvc/src/IOVDbParser.cxx b/Database/IOVDbSvc/src/IOVDbParser.cxx
index c5f04d44b9915839ea211173f12a486d13959b44..c966f002264c549cf857f5eb28dd59e89c2ffa3f 100644
--- a/Database/IOVDbSvc/src/IOVDbParser.cxx
+++ b/Database/IOVDbSvc/src/IOVDbParser.cxx
@@ -8,8 +8,8 @@
 #include "GaudiKernel/MsgStream.h"
 #include "IOVDbParser.h"
 
-IOVDbParser::IOVDbParser(const std::string& input, MsgStream* log) : 
-  m_log(log),
+IOVDbParser::IOVDbParser(const std::string& input, MsgStream& log) :
+  m_msg(log),
   m_valid(true)
 {
   // parse the input string as XML, decode into Key/Value pairs
@@ -42,7 +42,7 @@ IOVDbParser::IOVDbParser(const std::string& input, MsgStream* log) :
           // advance to the next part of the string, after '>' on closing tag
           iofs=input.find(">",iofs4)+1;
         } else {
-          *m_log << MSG::ERROR << 
+          m_msg << MSG::ERROR << 
             "Badly formed XML string, no closing tag for " << tag <<
             " in " << input << endmsg;
           m_valid=false;
@@ -65,7 +65,7 @@ IOVDbParser::IOVDbParser(const std::string& input, MsgStream* log) :
         iofs=iofs3+2;
       } else {
         // found a < but no closing >
-        *m_log << MSG::ERROR << 
+        m_msg << MSG::ERROR << 
           "Badly formed XML string, no closing < in input " <<
           input << endmsg;
         iofs=std::string::npos;
@@ -78,13 +78,12 @@ IOVDbParser::IOVDbParser(const std::string& input, MsgStream* log) :
     }
   }
   this->clean(); //rectify obsolete key names
-  if (m_log->level()<=MSG::VERBOSE) {
-    *m_log << MSG::VERBOSE << 
+  if (m_msg.level()<=MSG::VERBOSE) {
+    m_msg << MSG::VERBOSE << 
       "parseXML processed input string: " << input << endmsg;
-    for (KeyValMap::const_iterator itr=m_keys.begin();
-         itr!=m_keys.end();++itr) {
-      *m_log << MSG::VERBOSE << "Key: " << itr->first << " value:" << 
-        itr->second << endmsg;
+    for (KeyValMap::const_iterator itr=m_keys.begin();itr!=m_keys.end();++itr) {
+      m_msg << MSG::VERBOSE << "Key: " << itr->first << " value:" << 
+      itr->second << endmsg;
     }
   }
 }
@@ -135,7 +134,7 @@ void IOVDbParser::clean() {
 
 
 
-unsigned IOVDbParser::applyOverrides(const IOVDbParser& other, MsgStream* log) {
+unsigned IOVDbParser::applyOverrides(const IOVDbParser& other, MsgStream & log) {
   unsigned keyCounter=0;
   for (const auto& otherKeyValue : other.m_keys) {
     const std::string& otherKey=otherKeyValue.first;
@@ -144,12 +143,12 @@ unsigned IOVDbParser::applyOverrides(const IOVDbParser& other, MsgStream* log) {
     if (otherKey=="prefix") continue; //Ignore prefix
     KeyValMap::iterator it=m_keys.find(otherKey);
     if (it==m_keys.end()) {
-      *log << MSG::INFO << "Folder " << m_keys[""] << ", adding new key " << otherKey 
+      log << MSG::INFO << "Folder " << m_keys[""] << ", adding new key " << otherKey 
            << " with value " << otherValue << endmsg; 
       m_keys[otherKey]=otherValue;
     }
     else {
-      *log << MSG::INFO << "Folder " << m_keys[""] << ", Key: " << otherKey 
+      log << MSG::INFO << "Folder " << m_keys[""] << ", Key: " << otherKey 
            <<  "Overriding existing value " << m_keys[otherKey] << " to new value " << otherValue << endmsg;
       it->second=otherValue;
     }
diff --git a/Database/IOVDbSvc/src/IOVDbParser.h b/Database/IOVDbSvc/src/IOVDbParser.h
index 58a16c8ac3c6e8e16cd9bda1e3bbc8d4667c4471..98fedff0bf9b1269a5e5146e9f1eb865fa63f396 100644
--- a/Database/IOVDbSvc/src/IOVDbParser.h
+++ b/Database/IOVDbSvc/src/IOVDbParser.h
@@ -17,20 +17,21 @@ class IOVDbParser {
 public:
 
   IOVDbParser() = delete; 
-  IOVDbParser(const std::string& input, MsgStream* log);
+  IOVDbParser(const std::string& input, MsgStream& log);
+  
 
   bool isValid() const;
   bool getKey(const std::string& key, const std::string& devvalue, 
               std::string& value) const;
   std::string spaceStrip(const std::string& input) const;
   const std::string& folderName() const;
-  unsigned applyOverrides(const IOVDbParser& other, MsgStream* log);
+  unsigned applyOverrides(const IOVDbParser& other, MsgStream & log);
   bool operator==(const IOVDbParser& other) const; 
   std::string toString() const;
   void clean();
 
 private:
-  MsgStream* m_log;
+  MsgStream& m_msg;
   bool m_valid;
   typedef std::map<std::string, std::string> KeyValMap;
   KeyValMap m_keys;
diff --git a/Database/IOVDbSvc/src/IOVDbStringFunctions.cxx b/Database/IOVDbSvc/src/IOVDbStringFunctions.cxx
new file mode 100644
index 0000000000000000000000000000000000000000..40e89be67a3794621837e93c6c5d0e82c4fcc92a
--- /dev/null
+++ b/Database/IOVDbSvc/src/IOVDbStringFunctions.cxx
@@ -0,0 +1,181 @@
+/*
+  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+*/
+#include "IOVDbStringFunctions.h"
+#include <regex>
+#include <iostream>
+#include <algorithm>
+
+namespace IOVDbNamespace{
+  std::string 
+  spaceStrip(const std::string& input){
+    // return the input string stripped of leading/trailing spaces
+    std::string::size_type idx1=input.find_first_not_of(" ");
+    std::string::size_type idx2=input.find_last_not_of(" ");
+    if (idx1==std::string::npos || idx2==std::string::npos) {
+      return "";
+    } else {
+      return input.substr(idx1,1+idx2-idx1);
+    }
+  }
+  
+  int 
+  makeChannel(const std::string& strval, const int defchan) {
+    // construct a cool channelId from the string value (numeric)
+    // if empty, use the default value
+    if (strval!="") return std::stoi(strval);
+    return defchan;
+  }
+  
+  unsigned long long
+  iovFromTimeString(const std::string & iovString){
+    unsigned long long time=std::stoi(iovString);
+    return time*1000000000LL;
+  }
+  
+  unsigned long long
+  iovFromRunString(const std::string & runString){
+    unsigned long long run=std::stoi(runString);
+    return run<<32LL;
+  }
+  
+  unsigned long long
+  iovFromLumiBlockString(const std::string & lbString){
+    unsigned long long lb=std::stoll(lbString.c_str());
+    return lb;
+  }
+  
+  int 
+  parseClid(const std::string & addrHeaderStr){
+    //string of form
+    //<addrHeader><address_header service_type="256" clid="12345" /></addrHeader>
+    std::string regex=R"delim(clid\s*=\s*"([0-9]*)")delim";
+    std::regex re(regex);
+    std::smatch clidMatch;
+    bool match=std::regex_search(addrHeaderStr, clidMatch,re);
+    return (match) ? std::stoi(clidMatch[1]) : -1;
+  }
+  
+  std::string 
+  parseTypename(const std::string & description){
+    std::string regex=R"delim(<typeName>\s*([^\s]+)\s*</typeName>)delim";
+    std::regex re(regex);
+    std::smatch typeMatch;
+    bool match=std::regex_search(description, typeMatch,re);
+    return (match) ? std::string(typeMatch[1]) : std::string("");
+  }
+  
+  std::string 
+  deleteRegex(const std::string & original, const std::string & regex){
+    const std::regex delre(regex);
+    const std::string result = std::regex_replace(original,delre,"");
+    return result;
+  }
+  
+  
+  
+  std::string
+  quote(const std::string & sentence){
+    const std::string q("\"");
+    return q+sentence+q;
+  }
+  
+  std::string 
+  sanitiseFilename(const std::string & fname){
+    std::string newName{fname};
+    std::replace(newName.begin(), newName.end(), '/', '_');
+    return newName;
+  }
+  
+  std::string
+  replaceNULL(const std::string & possibleNULL){
+    std::string original{possibleNULL};
+    const std::string regex=R"delim( NULL)delim";
+    const std::regex nullre(regex);
+    const std::string result = std::regex_replace(original,nullre," null");
+    return result;
+  }
+  
+  std::string
+  sanitiseXml(const std::string & pseudoXmlString){
+    std::string result;
+    unsigned int strSize(pseudoXmlString.size());
+    unsigned int bufsize(strSize*1.1);
+    result.reserve(bufsize);
+    for(size_t pos = 0; pos != strSize; ++pos) {
+      switch(pseudoXmlString[pos]) {
+        //case '&':  result.append("&amp;");       break;
+        case '\"': result.append("\\\"");      break;
+        //case '\'': result.append("&apos;");      break;
+        //case '<':  result.append("&lt;");        break;
+        //case '>':  result.append("&gt;");        break;
+        default:   result.append(&pseudoXmlString[pos], 1); break;
+      }
+    }
+    return result;
+  }
+  
+  bool
+  tagIsMagic(const std::string & candidateTag){
+    const std::string regex=R"delim(TagInfo(Major|Minor)/.*)delim";
+    const std::regex magicx(regex);
+    return std::regex_match(candidateTag, magicx);
+  }
+  
+  std::vector<std::string>
+  parseMagicTag(const std::string & v){
+    std::vector<std::string> result;
+    std::string regex7=R"delim(TagInfo(Major|Minor)/([^/]*)/?([^/]*)?)delim";
+    std::regex matchmagic(regex7);
+    std::smatch x;
+    bool foundmagic=std::regex_match(v,x,matchmagic);
+    if (foundmagic){
+      for (const auto & i:x) 
+      if (i!="") result.push_back(i);
+    }
+    return result;
+  }
+  
+  std::vector<std::string>
+  parseLinkNames(const std::string linktext){
+    std::vector<std::string> v{};
+    //regex: 
+    //(anything except colon, multiple times) then _possibly_ (two colons and string of anything except colons)
+    // anything except colon) then (colon or end-of-line)
+    std::string linkRegexStr{"([^:]*(::[^:]*)?)(:|$)"};
+    std::regex linkMatchSpec(linkRegexStr); 
+    //give a token iterator using the regex and returning the first substring (i.e. the 
+    //bit before a single colon or line end, which would be for example "ALink" or "MyContext::AnotherLink" )
+    std::sregex_token_iterator pos(linktext.cbegin(), linktext.cend(),linkMatchSpec,{1});
+    std::sregex_token_iterator e;
+    for (;pos!=e;++pos)  {
+      // the resulting text _should not_ contain spaces, but strip it to be sure.
+      v.push_back(spaceStrip(pos->str()));                           
+    }
+    return v;                    
+  }
+  
+  std::pair<std::string, std::string>
+  tag2PrefixTarget(const std::vector<std::string> & tagParseResults){
+    std::string prefix{}, target{};
+    if (tagParseResults.size() == 4){ //4 is the size of result set if there is a prefix
+      prefix = tagParseResults[2]; //index of first path
+      target = tagParseResults[3]; //index of second path
+    } else {
+      target = tagParseResults[2];
+    }
+    return std::make_pair(prefix, target);
+  }
+  
+  bool
+  replaceServiceType71(std::string & addrHeader){
+    const std::size_t svcType = addrHeader.find("service_type=\"71\"");
+    if (svcType != std::string::npos) {
+      addrHeader.replace(svcType, 17, "service_type=\"256\"");
+      return true;
+    }
+    return false;
+  }
+
+  
+}
diff --git a/Database/IOVDbSvc/src/IOVDbStringFunctions.h b/Database/IOVDbSvc/src/IOVDbStringFunctions.h
new file mode 100644
index 0000000000000000000000000000000000000000..f255e9d143fbee6c0be9f835b1e218bd0f2bdfd2
--- /dev/null
+++ b/Database/IOVDbSvc/src/IOVDbStringFunctions.h
@@ -0,0 +1,112 @@
+/*
+  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+*/
+//@file IOVDbStringFunctions.h
+//@brief Helper functions for string manipulation and parsing
+//@author Shaun Roe
+#ifndef IOVDbStringFunctions_H
+#define IOVDbStringFunctions_H
+
+#include <string>
+#include <vector>
+#include <utility>
+#include <limits>
+
+namespace IOVDbNamespace{
+
+  ///Trim leading and trailing spaces,return a new trimmed string
+  std::string 
+  spaceStrip(const std::string& input);
+  
+  int makeChannel(const std::string& strval, const int defchan);
+  
+  ///Parse a channel specification string of the format ":3, 65:67,100:120, 130: "
+  template <class IntType>
+  std::vector<std::pair<IntType, IntType>>
+  parseChannelSpec(const std::string & chanspecString){
+    typedef std::pair<IntType, IntType> ChanRange;
+    const auto defaults=ChanRange(0,std::numeric_limits<IntType>::max());
+    //
+    std::vector<ChanRange> result;
+    std::string::size_type index;
+    std::string rangespec, chanspec(chanspecString);
+    bool first=true;
+    do {
+        index=chanspec.find(',');
+        if (index!=std::string::npos) {
+            rangespec=chanspec.substr(0,index);
+            chanspec=chanspec.substr(index+1,chanspec.size());
+        } else {
+            rangespec=chanspec;
+        }
+        if (rangespec!="") {
+            // parse the range specification, look for : separator between limits
+            std::string::size_type icol=rangespec.find(':');
+            int lower,upper;
+            if (icol!=std::string::npos) {
+                lower=makeChannel(spaceStrip(rangespec.substr(0,icol)),defaults.first);
+                upper=makeChannel(spaceStrip(rangespec.substr(icol+1,rangespec.size())),defaults.second);
+            } else {
+                lower=atol(spaceStrip(rangespec).c_str());
+                upper=lower;
+            }
+            if (first) {
+                first=false;
+            } 
+            result.push_back(ChanRange(lower,upper));
+        }
+    } while (index!=std::string::npos);
+    return result;
+  }
+
+  unsigned long long
+  iovFromTimeString(const std::string & iovString);
+  
+  unsigned long long
+  iovFromRunString(const std::string & runString);
+  
+  unsigned long long
+  iovFromLumiBlockString(const std::string & lbString);
+  
+  int 
+  parseClid(const std::string & addrHeaderStr);
+  
+  std::string 
+  parseTypename(const std::string & description);
+  
+  std::string 
+  deleteRegex(const std::string & original, const std::string & regex);
+  
+  std::string
+  quote(const std::string & sentence);
+  
+  std::string 
+  sanitiseFilename(const std::string & fname);
+  
+  std::string
+  replaceNULL(const std::string & possibleNULL);
+  
+  std::string
+  sanitiseXml(const std::string & pseudoXmlString);
+  
+  bool
+  tagIsMagic(const std::string & candidateTag);
+  
+  std::vector<std::string>
+  parseMagicTag(const std::string & candidateTag);
+  
+  std::pair<std::string, std::string>
+  tag2PrefixTarget(const std::vector<std::string>& parseResult);
+
+  bool
+  replaceServiceType71(std::string & addrHeader);
+
+  
+  //! Parse string of format "A:X::B:C" to "A" , "X::B", "C"
+  std::vector<std::string>
+  parseLinkNames(const std::string linktext);
+  
+  
+}
+  
+#endif
diff --git a/Database/IOVDbSvc/src/IOVDbSvc.cxx b/Database/IOVDbSvc/src/IOVDbSvc.cxx
index 9136b1230040dbf77328bd00dbb018bbf10373ca..f75d759fbf00402af88a76636ed2f04d0e090fba 100644
--- a/Database/IOVDbSvc/src/IOVDbSvc.cxx
+++ b/Database/IOVDbSvc/src/IOVDbSvc.cxx
@@ -98,13 +98,14 @@ IOVDbSvc::IOVDbSvc( const std::string& name, ISvcLocator* svc )
     m_h_poolSvc    ("PoolSvc", name),
     m_h_metaDataTool("IOVDbMetaDataTool"),
     m_h_tagInfoMgr("TagInfoMgr", name),
-    m_log(0),
+    //m_log(0),
     m_poolPayloadRequested(false),
     m_poolSvcContext(0),
     m_state (INITIALIZATION),
     m_globalTag(""),
     m_iovslop(),
-    m_abort(false)
+    m_abort(false)//,
+    //m_msg("IOVDbSvc")
 {
   // declare all properties
   declareProperty("dbConnection",          m_par_defaultConnection);
@@ -147,11 +148,11 @@ IOVDbSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) {
 StatusCode IOVDbSvc::initialize() {
   if (StatusCode::SUCCESS!=AthService::initialize()) return StatusCode::FAILURE;
   // initialise message stream after service init to get correct print level
-  m_log=new MsgStream(msgSvc(),name());
+  //m_log=new MsgStream(msgSvc(),name());
   // subscribe to events
   ServiceHandle<IIncidentSvc> incSvc("IncidentSvc",name());
   if (StatusCode::SUCCESS!=incSvc.retrieve()) {
-    *m_log << MSG::ERROR << "Unable to get the IncidentSvc" << endmsg;
+    ATH_MSG_ERROR( "Unable to get the IncidentSvc" );
     return StatusCode::FAILURE;
   }
   long int pri=100;
@@ -169,44 +170,40 @@ StatusCode IOVDbSvc::initialize() {
   
   if (StatusCode::SUCCESS==m_h_poolSvc->connect(pool::ITransaction::READ,
                                                 m_poolSvcContext)) {
-    *m_log << MSG::INFO << "Opened read transaction for POOL PersistencySvc"
-           << endmsg;
+    ATH_MSG_INFO( "Opened read transaction for POOL PersistencySvc");
   } else {
     // We only emit info for failure to connect (for the moment? RDS 01/2008)
-    *m_log << MSG::INFO << "Cannot connect to POOL PersistencySvc" << endmsg;
+    ATH_MSG_INFO( "Cannot connect to POOL PersistencySvc" );
   }
 
   // print warnings/info depending on state of job options
   if (!m_par_manageConnections)
-    *m_log << MSG::INFO << "COOL connection management disabled - connections kept open throughout job" << endmsg;
+    ATH_MSG_INFO( "COOL connection management disabled - connections kept open throughout job" );
   if (!m_par_managePoolConnections)
-    *m_log << MSG::INFO << "POOL file connection management disabled - files kept open throught job" << endmsg;
+    ATH_MSG_INFO( "POOL file connection management disabled - files kept open throught job" );
   if (m_par_maxNumPoolFiles.value() > 0)
-    *m_log << MSG::INFO << "Only " << m_par_maxNumPoolFiles.value() <<  
-      " POOL conditions files will be open at once" << endmsg;
+    ATH_MSG_INFO( "Only " << m_par_maxNumPoolFiles.value() <<  " POOL conditions files will be open at once" );
   if (m_par_forceRunNumber.value() > 0 || m_par_forceLumiblockNumber.value() > 0)
-    *m_log << MSG::WARNING << "Global run/LB number forced to be [" <<
+    ATH_MSG_WARNING( "Global run/LB number forced to be [" <<
       m_par_forceRunNumber.value() << "," << m_par_forceLumiblockNumber.value()
-           <<  "]" << endmsg;
+           <<  "]" );
   if (m_par_forceTimestamp.value() > 0) 
-    *m_log << MSG::WARNING << "Global timestamp forced to be " <<
-      m_par_forceTimestamp.value() << endmsg;
+    ATH_MSG_WARNING( "Global timestamp forced to be " <<
+      m_par_forceTimestamp.value() );
   if (m_par_cacheRun.value() > 0) 
-    *m_log << MSG::INFO << "Run-LB data will be cached in groups of " << 
-      m_par_cacheRun.value() << " runs" << endmsg;
+    ATH_MSG_INFO( "Run-LB data will be cached in groups of " << 
+      m_par_cacheRun.value() << " runs" );
   if (m_par_cacheTime.value() > 0)
-    *m_log << MSG::INFO << "Timestamp data will be cached in groups of "
-           << m_par_cacheTime.value() << " seconds" << endmsg;
+    ATH_MSG_INFO( "Timestamp data will be cached in groups of "
+           << m_par_cacheTime.value() << " seconds" );
   if (m_par_cacheAlign > 0) 
-    *m_log << MSG::INFO << "Cache alignment will be done in " << 
-      m_par_cacheAlign.value() << " slices" << endmsg;
+    ATH_MSG_INFO( "Cache alignment will be done in " << 
+      m_par_cacheAlign.value() << " slices" );
   if (m_par_onlineMode) 
-    *m_log << MSG::INFO << 
-      "Online mode ignoring potential missing channels outside cache" << 
-      endmsg;
+    ATH_MSG_INFO( 
+      "Online mode ignoring potential missing channels outside cache" );
   if (m_par_checklock)
-    *m_log << MSG::INFO << "Tags will be required to be locked"
-           << endmsg;
+    ATH_MSG_INFO( "Tags will be required to be locked");
 
   // make sure iovTime is undefined
   m_iovTime.reset();
@@ -219,7 +216,7 @@ StatusCode IOVDbSvc::initialize() {
     // default connection is readonly if no : in name (i.e. logical conn)
     bool readonly=(m_par_defaultConnection.find(':')==std::string::npos);
     m_connections.push_back(new IOVDbConn(m_par_defaultConnection,readonly,
-                                          m_log));
+                                          msg()));
   }
 
   // set time of timestampslop in nanoseconds
@@ -228,8 +225,8 @@ StatusCode IOVDbSvc::initialize() {
   // check for global tag in jobopt, which will override anything in input file
   if (m_par_globalTag!="") {
     m_globalTag=m_par_globalTag;
-    *m_log << MSG::INFO << "Global tag: " << m_par_globalTag << 
-      " set from joboptions" << endmsg;
+    ATH_MSG_INFO( "Global tag: " << m_par_globalTag << 
+      " set from joboptions" );
   }
 
   // setup folders and process tag overrides
@@ -237,10 +234,9 @@ StatusCode IOVDbSvc::initialize() {
 
   // Set state to initialize
   m_state=IOVDbSvc::INITIALIZATION;
-  *m_log << MSG::INFO << "Initialised with " << m_connections.size() << 
-    " connections and " << m_foldermap.size() << " folders" << endmsg;
-  *m_log << MSG::INFO << "Service IOVDbSvc initialised successfully" <<
-    endmsg;
+  ATH_MSG_INFO( "Initialised with " << m_connections.size() << 
+    " connections and " << m_foldermap.size() << " folders" );
+  ATH_MSG_INFO( "Service IOVDbSvc initialised successfully" );
   return StatusCode::SUCCESS;
 }
 
@@ -267,9 +263,8 @@ StatusCode IOVDbSvc::finalize() {
     }
     delete folder;
   }
-  *m_log << MSG::INFO << "Total payload read from COOL: " << nread << 
-    " bytes in (( " << std::fixed << std::setw(9) << std::setprecision(2) <<
-    readtime << " ))s" << endmsg;
+  ATH_MSG_INFO(  " bytes in (( " << std::fixed << std::setw(9) << std::setprecision(2) <<
+    readtime << " ))s" );
 
   // close and delete connections, printing time in each one
   for (ConnVec::iterator itr=m_connections.begin(); itr!=m_connections.end();
@@ -282,7 +277,7 @@ StatusCode IOVDbSvc::finalize() {
     delete *itr;
   }
   // finally remove the msg svc
-  delete m_log;
+  //delete m_log;
   return AthService::finalize();
 }
 
@@ -290,14 +285,11 @@ cool::IDatabasePtr IOVDbSvc::getDatabase(bool readOnly) {
   // get default database connection
   cool::IDatabasePtr dbconn;
   if (m_par_defaultConnection=="" || m_connections.size()==0) {
-    *m_log << MSG::ERROR << "No default COOL database connection is available"
-           << endmsg;
+    ATH_MSG_INFO( "No default COOL database connection is available");
     dbconn.reset();
   } else {
     if (m_connections[0]->isReadOnly()!=readOnly) {
-      *m_log << MSG::WARNING << 
-        "Changing state of default connection to readonly=" << readOnly 
-             << endmsg;
+      ATH_MSG_INFO("Changing state of default connection to readonly=" << readOnly );
       m_connections[0]->setReadOnly(readOnly);
     }
     dbconn=m_connections[0]->getCoolDb();
@@ -309,8 +301,7 @@ StatusCode IOVDbSvc::preLoadAddresses(StoreID::type storeID,tadList& tlist) {
   // Read information for folders and setup TADs
   if (storeID!=StoreID::DETECTOR_STORE) return StatusCode::SUCCESS;
   // Preloading of addresses should be done ONLY for detector store
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "preLoadAddress: storeID -> " << storeID << endmsg;
+  ATH_MSG_DEBUG( "preLoadAddress: storeID -> " << storeID );
   // check FLMD of input, see if any requested folders are available there
   const DataHandle<IOVMetaDataContainer> cont;
   const DataHandle<IOVMetaDataContainer> contEnd;
@@ -324,25 +315,19 @@ StatusCode IOVDbSvc::preLoadAddresses(StoreID::type storeID,tadList& tlist) {
       for (FolderMap::const_iterator fitr=m_foldermap.begin();
            fitr!=m_foldermap.end();++fitr) {
         // take data from FLMD only if tag override is NOT set
-        if (fitr->second->folderName()==fname && 
-            !(fitr->second->tagOverride())) {
-          *m_log << MSG::INFO << "Folder " << fname << 
-            " will be taken from file metadata" << endmsg;
+        if (fitr->second->folderName()==fname && !(fitr->second->tagOverride())) {
+          ATH_MSG_INFO( "Folder " << fname << " will be taken from file metadata" );
           fitr->second->setMetaCon(cont.cptr());
           // print metadata if in debug mode
-          if (m_log->level()<=MSG::DEBUG) printMetaDataContainer(cont.cptr());
+          //ATH_MSG_DEBUG( printMetaDataContainer(cont.cptr()));
           ++nused;
           break;
         }
       }
     }
-    *m_log << MSG::INFO << "Found " << ncontainers << 
-      " metadata containers in input file, " << nused << " will be used" << 
-      endmsg;
+    ATH_MSG_INFO( "Found " << ncontainers <<  " metadata containers in input file, " << nused << " will be used");
   } else {
-    if (m_log->level()<=MSG::DEBUG) *m_log << MSG::DEBUG << 
-                                      "Could not retrieve IOVMetaDataContainer objects from MetaDataStore" << 
-                                      endmsg;
+    ATH_MSG_DEBUG( "Could not retrieve IOVMetaDataContainer objects from MetaDataStore" );
   }
 
   // Remove folders which should only be read from file meta data, but
@@ -354,10 +339,8 @@ StatusCode IOVDbSvc::preLoadAddresses(StoreID::type storeID,tadList& tlist) {
   std::vector<std::string> keysToDelete;
   for (FolderMap::iterator fitr = m_foldermap.begin(); fitr != m_foldermap.end(); ++fitr) {
     if (fitr->second->fromMetaDataOnly() && !fitr->second->readMeta()) {
-      *m_log << MSG::INFO << "preLoadAddresses: Removing folder " << 
-        fitr->second->folderName() << 
-        ". It should only be in the file meta data and was not found." 
-             << endmsg;
+      ATH_MSG_INFO( "preLoadAddresses: Removing folder " << fitr->second->folderName() << 
+        ". It should only be in the file meta data and was not found." );
       keysToDelete.push_back(fitr->first);
     }
   }
@@ -370,8 +353,7 @@ StatusCode IOVDbSvc::preLoadAddresses(StoreID::type storeID,tadList& tlist) {
       m_foldermap.erase(fitr);
     }
     else {
-      *m_log << MSG::ERROR << "preLoadAddresses: Could not find folder " << *sit 
-             << " for removal" << endmsg;
+      ATH_MSG_ERROR( "preLoadAddresses: Could not find folder " << *sit << " for removal" );
     }
   }
   
@@ -400,25 +382,20 @@ StatusCode IOVDbSvc::preLoadAddresses(StoreID::type storeID,tadList& tlist) {
             oldconn=(*citr);
           }
           if (tad==0) {
-            *m_log << MSG::ERROR << "preLoadFolder failed for folder " << folder->folderName() << endmsg;
+            ATH_MSG_ERROR( "preLoadFolder failed for folder " << folder->folderName() );
             return StatusCode::FAILURE;
           }
           // for write-metadata folder, request data preload
           if (folder->writeMeta()) {
-            if (StatusCode::SUCCESS!=m_h_IOVSvc->preLoadDataTAD(tad.get(),
-                                                                folder->eventStore())) {
-              *m_log << MSG::ERROR << 
-                "Could not request IOVSvc to preload metadata for " << 
-                folder->folderName() << endmsg;
+            if (StatusCode::SUCCESS!=m_h_IOVSvc->preLoadDataTAD(tad.get(),folder->eventStore())) {
+              ATH_MSG_ERROR( "Could not request IOVSvc to preload metadata for " << folder->folderName() );
               return StatusCode::FAILURE;
             }
           } else {
             // for other folders, just preload TAD (not data)
             if (StatusCode::SUCCESS!=m_h_IOVSvc->preLoadTAD(tad.get(),
                                                             folder->eventStore())) {
-              *m_log << MSG::ERROR << 
-                "Could not request IOVSvc to preload metadata for " << 
-                folder->folderName() << endmsg;
+              ATH_MSG_ERROR( "Could not request IOVSvc to preload metadata for " << folder->folderName() );
               return StatusCode::FAILURE;
             }
           }
@@ -446,8 +423,7 @@ StatusCode IOVDbSvc::preLoadAddresses(StoreID::type storeID,tadList& tlist) {
   m_foldermap=newmap;
   // fill global and explicit folder tags into TagInfo
   if (StatusCode::SUCCESS!=fillTagInfo()) 
-    *m_log << MSG::ERROR << 
-      "Could not fill TagInfo object from preLoadAddresses" << endmsg;
+    ATH_MSG_ERROR("Could not fill TagInfo object from preLoadAddresses" );
   return StatusCode::SUCCESS;
 }
 
@@ -474,16 +450,14 @@ StatusCode IOVDbSvc::updateAddress(StoreID::type storeID, SG::TransientAddress*
   const std::string& key=tad->name();
   FolderMap::const_iterator fitr=m_foldermap.find(key);
   if (fitr==m_foldermap.end()) {
-    if (m_log->level()<=MSG::VERBOSE) 
-      *m_log << MSG::VERBOSE << 
-        "updateAddress cannot find description for TAD " << key << endmsg;
+    ATH_MSG_VERBOSE( 
+        "updateAddress cannot find description for TAD " << key );
     return StatusCode::FAILURE;
   }
   IOVDbFolder* folder=fitr->second;
   if (folder->clid()!=tad->clID()) {
-    if (m_log->level()<=MSG::VERBOSE)
-      *m_log << MSG::VERBOSE << "CLID for TAD " << key << " is " << tad->clID()
-             << " but expecting " << folder->clid() << endmsg;
+    ATH_MSG_VERBOSE( "CLID for TAD " << key << " is " << tad->clID()
+             << " but expecting " << folder->clid() );
     
     return StatusCode::FAILURE;
   }
@@ -491,8 +465,7 @@ StatusCode IOVDbSvc::updateAddress(StoreID::type storeID, SG::TransientAddress*
   // IOVDbSvc will satisfy the request, using already found folder
   // now determine the current IOVTime
   if (m_state==IOVDbSvc::INITIALIZATION && !m_iovTime.isValid()) {
-    if (m_log->level()<=MSG::DEBUG) *m_log << MSG::DEBUG << 
-                                      "updateAddress: in initialisation phase and no iovTime defined" << endmsg;
+    ATH_MSG_DEBUG( "updateAddress: in initialisation phase and no iovTime defined" );
     return::StatusCode::SUCCESS;
   }
   if (m_state==IOVDbSvc::EVENT_LOOP) {
@@ -506,22 +479,14 @@ StatusCode IOVDbSvc::updateAddress(StoreID::type storeID, SG::TransientAddress*
       uint64_t nsTime=evt->event_ID()->time_stamp()*1000000000LL;
       nsTime += evt->event_ID()->time_stamp_ns_offset();
       m_iovTime.setTimestamp(nsTime);
-      if (m_log->level()<=MSG::DEBUG)
-        *m_log << MSG::DEBUG <<
-          "updateAddress - using iovTime from EventInfo: " << 
-          m_iovTime << endmsg;
+      ATH_MSG_DEBUG( "updateAddress - using iovTime from EventInfo: " << m_iovTime);
     } else {
       // failed to get event info - just return success
-      if (m_log->level()<=MSG::DEBUG)
-        *m_log << MSG::DEBUG << "Could not get event - initialise phase" 
-               << endmsg;
+      ATH_MSG_DEBUG( "Could not get event - initialise phase");
       return StatusCode::SUCCESS;
     }
   } else {
-    if (m_log->level()<=MSG::DEBUG)
-      *m_log << MSG::DEBUG << 
-        "updateAddress: using iovTime from init/beginRun: " << m_iovTime 
-             << endmsg;
+    ATH_MSG_DEBUG("updateAddress: using iovTime from init/beginRun: " << m_iovTime);
   }
 
   // check consistency of global tag and database instance, if set
@@ -529,17 +494,15 @@ StatusCode IOVDbSvc::updateAddress(StoreID::type storeID, SG::TransientAddress*
   // this is only done here as need global tag to be set even if read from file
   if (!m_par_dbinst.empty() && !m_globalTag.empty()) {
     const std::string tagstub=m_globalTag.substr(0,7);
-    if (m_log->level()<=MSG::DEBUG)
-      *m_log << MSG::DEBUG << "Checking " << m_par_dbinst << " against " <<
-        tagstub << endmsg;
+    ATH_MSG_DEBUG( "Checking " << m_par_dbinst << " against " <<tagstub );
     if (((m_par_dbinst=="COMP200" || m_par_dbinst=="CONDBR2") && 
          (tagstub!="COMCOND" && tagstub!="CONDBR2")) ||
         (m_par_dbinst=="OFLP200" && (tagstub!="OFLCOND" && tagstub!="CMCCOND"))) {
-      *m_log << MSG::FATAL << "Likely incorrect conditions DB configuration! " 
+      ATH_MSG_FATAL( "Likely incorrect conditions DB configuration! " 
              <<  "Attached to database instance " << m_par_dbinst <<
-        " but global tag begins " << tagstub << endmsg;
-      *m_log << MSG::FATAL << "See Atlas/CoolTroubles wiki for details," << 
-        " or set IOVDbSvc.DBInstance=\"\" to disable check" << endmsg;
+        " but global tag begins " << tagstub );
+      ATH_MSG_FATAL( "See Atlas/CoolTroubles wiki for details," << 
+        " or set IOVDbSvc.DBInstance=\"\" to disable check" );
       return StatusCode::FAILURE;
     }
   }
@@ -551,11 +514,9 @@ StatusCode IOVDbSvc::updateAddress(StoreID::type storeID, SG::TransientAddress*
     // mark this folder as not-dropped so cache-read will succeed
     folder->setDropped(false);
     // reload cache for this folder (and all others sharing this DB connection)
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << "Triggering cache load for folder " << 
-        folder->folderName() << endmsg;
+    ATH_MSG_DEBUG( "Triggering cache load for folder " << folder->folderName());
     if (StatusCode::SUCCESS!=loadCaches(folder->conn())) {
-      *m_log << MSG::ERROR << "Cache load failed for folder " <<  folder->folderName() << endmsg;
+      ATH_MSG_ERROR( "Cache load failed for folder " <<  folder->folderName() );
       return StatusCode::FAILURE;
     }
   }
@@ -569,8 +530,7 @@ StatusCode IOVDbSvc::updateAddress(StoreID::type storeID, SG::TransientAddress*
                                         auditorSvc(), "preLoadProxy");
     if (!folder->getAddress(vkey,&(*m_h_persSvc),m_poolSvcContext,address,
                             range,m_poolPayloadRequested)) {
-      *m_log << MSG::ERROR << "getAddress failed for folder " << 
-        folder->folderName() << endmsg;
+      ATH_MSG_ERROR( "getAddress failed for folder " << folder->folderName() );
       return StatusCode::FAILURE;
     }
   }
@@ -585,8 +545,7 @@ StatusCode IOVDbSvc::updateAddress(StoreID::type storeID, SG::TransientAddress*
   // Pass range onto IOVSvc
   if (StatusCode::SUCCESS!=m_h_IOVSvc->setRange(tad->clID(),tad->name(),
                                                 range,folder->eventStore())) {
-    *m_log << MSG::ERROR << "setRange failed for folder " << 
-      folder->folderName() << endmsg;
+    ATH_MSG_ERROR( "setRange failed for folder " << folder->folderName() );
     return StatusCode::FAILURE;
   }
   tad->setAddress(address);
@@ -602,31 +561,23 @@ StatusCode IOVDbSvc::getRange( const CLID&        clid,
                                std::string&       tag,
                                IOpaqueAddress*&   address) {
 
-  *m_log << MSG::DEBUG << "getRange  clid: " << clid << " key: \""
-         << dbKey << "\"  t: " << time << endmsg;
+  ATH_MSG_DEBUG( "getRange  clid: " << clid << " key: \""<< dbKey << "\"  t: " << time );
 
   const std::string& key=dbKey;
   FolderMap::const_iterator fitr=m_foldermap.find(key);
   if (fitr==m_foldermap.end()) {
-    if (m_log->level()<=MSG::VERBOSE) 
-      *m_log << MSG::VERBOSE << 
-        "getRange cannot find description for dbKey " << key << endmsg;
+    ATH_MSG_VERBOSE("getRange cannot find description for dbKey " << key );
     return StatusCode::FAILURE;
   }
   IOVDbFolder* folder=fitr->second;
   if (folder->clid()!=clid) {
-    if (m_log->level()<=MSG::VERBOSE)
-      *m_log << MSG::VERBOSE << "supplied CLID for " << key << " is " 
+    ATH_MSG_VERBOSE( "supplied CLID for " << key << " is " 
              << clid
-             << " but expecting " << folder->clid() << endmsg;
+             << " but expecting " << folder->clid() );
     
     return StatusCode::FAILURE;
   }
 
-  // *m_log << MSG::INFO << "folderName: " << folder->folderName()
-  //        << " key: " << folder->key() 
-  //        << " resolvedTag: " << folder->resolvedTag()
-  //        << endmsg;
 
   /// FIXME?
   tag = folder->key();
@@ -637,17 +588,15 @@ StatusCode IOVDbSvc::getRange( const CLID&        clid,
   // this is only done here as need global tag to be set even if read from file
   if (!m_par_dbinst.empty() && !m_globalTag.empty()) {
     const std::string tagstub=m_globalTag.substr(0,7);
-    if (m_log->level()<=MSG::DEBUG)
-      *m_log << MSG::DEBUG << "Checking " << m_par_dbinst << " against " <<
-        tagstub << endmsg;
+    ATH_MSG_DEBUG( "Checking " << m_par_dbinst << " against " <<tagstub );
     if (((m_par_dbinst=="COMP200" || m_par_dbinst=="CONDBR2") && 
          (tagstub!="COMCOND" && tagstub!="CONDBR2")) ||
         (m_par_dbinst=="OFLP200" && (tagstub!="OFLCOND" && tagstub!="CMCCOND"))) {
-      *m_log << MSG::FATAL << "Likely incorrect conditions DB configuration! " 
+      ATH_MSG_FATAL( "Likely incorrect conditions DB configuration! " 
              <<  "Attached to database instance " << m_par_dbinst <<
-        " but global tag begins " << tagstub << endmsg;
-      *m_log << MSG::FATAL << "See Atlas/CoolTroubles wiki for details," << 
-        " or set IOVDbSvc.DBInstance=\"\" to disable check" << endmsg;
+        " but global tag begins " << tagstub );
+      ATH_MSG_FATAL( "See Atlas/CoolTroubles wiki for details," << 
+        " or set IOVDbSvc.DBInstance=\"\" to disable check" );
       return StatusCode::FAILURE;
     }
   }
@@ -659,11 +608,9 @@ StatusCode IOVDbSvc::getRange( const CLID&        clid,
     // mark this folder as not-dropped so cache-read will succeed
     folder->setDropped(false);
     // reload cache for this folder (and all others sharing this DB connection)
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << "Triggering cache load for folder " << 
-        folder->folderName() << endmsg;
+    ATH_MSG_DEBUG( "Triggering cache load for folder " << folder->folderName() );
     if (StatusCode::SUCCESS!=loadCaches(folder->conn(),&time)) {
-      *m_log << MSG::ERROR << "Cache load failed for folder " <<  folder->folderName() << endmsg;
+      ATH_MSG_ERROR( "Cache load failed for folder " <<  folder->folderName() );
       return StatusCode::FAILURE;
     }
   }
@@ -677,19 +624,12 @@ StatusCode IOVDbSvc::getRange( const CLID&        clid,
                                         auditorSvc(), "preLoadProxy");
     if (!folder->getAddress(vkey,&(*m_h_persSvc),m_poolSvcContext,address,
                             range,m_poolPayloadRequested)) {
-      *m_log << MSG::ERROR << "getAddress failed for folder " << 
-        folder->folderName() << endmsg;
+      ATH_MSG_ERROR("getAddress failed for folder " <<folder->folderName() );
       return StatusCode::FAILURE;
     }
   }
 
-  // // reduce minimum IOV of timestamp folders to avoid 'thrashing' 
-  // // due to events slightly out of order in HLT
-  // if (folder->timeStamp()) {
-  //   cool::ValidityKey start=range.start().timestamp();
-  //   if (start>m_iovslop) start-=m_iovslop;
-  //   range=IOVRange(IOVTime(start),range.stop());
-  // }
+ 
 
   // Special handling for open-ended ranges in extensible folders:
   if (folder->extensible() && isOpenEnded (range, folder->timeStamp())) {
@@ -736,23 +676,19 @@ StatusCode IOVDbSvc::signalBeginRun(const IOVTime& beginRunTime,
     m_iovTime.setRunEvent (conditionsRun, m_iovTime.event());
   }
 
-  if (m_log->level()<MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "signalBeginRun> begin run time " << m_iovTime 
-           << endmsg;
+  ATH_MSG_DEBUG( "signalBeginRun> begin run time " << m_iovTime);
   if(!m_par_onlineMode) return StatusCode::SUCCESS;
   static int first=0;
   if (!first) {
     first=1; 
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << "first call SKIPPING ... " << endmsg;
+    ATH_MSG_DEBUG( "first call SKIPPING ... " );
     return StatusCode::SUCCESS;
   }
   // all other stuff is event based so happens after this. 
   // this is before first event of each run
-  if (m_log->level()<=MSG::DEBUG)  {
-    *m_log << MSG::DEBUG << "In online mode will recheck ... " << endmsg;
-    *m_log << MSG::DEBUG << "First reload PoolCataloge ... " << endmsg;
-  }
+  ATH_MSG_DEBUG( "In online mode will recheck ... " );
+  ATH_MSG_DEBUG( "First reload PoolCataloge ... " );
+  
   pool::IFileCatalog* catalog=
     const_cast<pool::IFileCatalog*>(m_h_poolSvc->catalog());
   catalog->commit();
@@ -766,7 +702,7 @@ StatusCode IOVDbSvc::signalBeginRun(const IOVTime& beginRunTime,
       //request for database activates connection
       cool::IDatabasePtr dbconn=(*dbi)->getCoolDb();
       if (dbconn.get()==0) {
-        *m_log << MSG::FATAL << "Conditions database connection " <<  (*dbi)->name() << " cannot be opened - STOP" << endmsg;
+        ATH_MSG_FATAL( "Conditions database connection " <<  (*dbi)->name() << " cannot be opened - STOP" );
         return StatusCode::FAILURE;
       }
       for (FolderMap::iterator fitr=m_foldermap.begin();fitr!=m_foldermap.end();++fitr) { 
@@ -777,8 +713,7 @@ StatusCode IOVDbSvc::signalBeginRun(const IOVTime& beginRunTime,
         {
           Gaudi::Guards::AuditorGuard auditor(std::string("FldrCache:")+folder->folderName(), auditorSvc(), "preLoadProxy");
           if (!folder->loadCacheIfDbChanged(vkey, m_globalTag, dbconn, m_h_IOVSvc)) {
-            *m_log << MSG::ERROR << "Problem RELOADING: " << folder->folderName()
-                   << endmsg;
+            ATH_MSG_ERROR( "Problem RELOADING: " << folder->folderName());
             return StatusCode::FAILURE;
           }
         }
@@ -798,9 +733,8 @@ void IOVDbSvc::handle( const Incident& inc) {
   // Handle incidents:
   // BeginEvent to set IOVDbSvc state to EVENT_LOOP
   // StoreCleared or EndOfBeginRun to close any open POOL files
-  if (m_log->level() <= MSG::VERBOSE)
-    *m_log << MSG::VERBOSE << "entering handle(), incident type " << inc.type()
-           << " from " << inc.source() << endmsg;
+  ATH_MSG_VERBOSE( "entering handle(), incident type " << inc.type()
+           << " from " << inc.source() );
   if (inc.type()=="BeginEvent") {
     m_state=IOVDbSvc::EVENT_LOOP;
   } else {
@@ -819,22 +753,16 @@ void IOVDbSvc::handle( const Incident& inc) {
         // reset POOL connection to close all open conditions POOL files
         m_poolPayloadRequested=false;
         if (StatusCode::SUCCESS==m_h_poolSvc->disconnect(m_poolSvcContext)) {
-          if (m_log->level()<=MSG::DEBUG) 
-            *m_log << MSG::DEBUG << "Successfully closed input POOL connections"
-                   << endmsg;
+          ATH_MSG_DEBUG( "Successfully closed input POOL connections");
         } else {
-          *m_log << MSG::WARNING << "Unable to close input POOL connections" << 
-            endmsg;
+          ATH_MSG_WARNING( "Unable to close input POOL connections" );
         }
         // reopen transaction
         if (StatusCode::SUCCESS==m_h_poolSvc->connect(pool::ITransaction::READ,
                                                       m_poolSvcContext)) {
-          if (m_log->level()<=MSG::DEBUG)                   *m_log << MSG::DEBUG << 
-                                                              "Reopend read transaction for POOL conditions input files" << endmsg;
+          ATH_MSG_DEBUG("Reopend read transaction for POOL conditions input files" );
         } else {
-          *m_log << MSG::WARNING << 
-            "Cannot reopen read transaction for POOL conditions input files" 
-                 << endmsg;
+          ATH_MSG_WARNING("Cannot reopen read transaction for POOL conditions input files");
         }
       }
     }
@@ -845,12 +773,11 @@ StatusCode IOVDbSvc::registerTagInfoCallback() {
   // register callback for taginfo handling
   // for the moment, this calls processTagInfo directly, rather than going
   // via a call back (following RDS 08/2006)
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "registerTagInfoCallback called" << endmsg;
+  ATH_MSG_DEBUG( "registerTagInfoCallback called" );
   std::list<std::string> alist;
   int a=0;
   if (StatusCode::SUCCESS!=processTagInfo(a,alist)) {
-    *m_log << MSG::ERROR << "Cannot process TagInfo" << endmsg;
+    ATH_MSG_ERROR( "Cannot process TagInfo" );
     return StatusCode::FAILURE;
   } else {
     return StatusCode::SUCCESS;
@@ -862,33 +789,27 @@ StatusCode IOVDbSvc::processTagInfo(IOVSVC_CALLBACK_ARGS) {
   // Set GlobalTag and any folder-specific overrides if given
   const TagInfo* tagInfo=0;
   if (StatusCode::SUCCESS!=m_h_detStore->retrieve(tagInfo)) {
-    *m_log << MSG::ERROR << "No TagInfo in DetectorStore" << endmsg;
+    ATH_MSG_ERROR( "No TagInfo in DetectorStore" );
     return StatusCode::FAILURE;
   }
   // dump out contents of TagInfo
-  if (m_log->level()<=MSG::DEBUG) {
-    *m_log << MSG::DEBUG << "Tags from input TagInfo:" << endmsg;
-    tagInfo->printTags(*m_log);
-  }
+  ATH_MSG_DEBUG( "Tags from input TagInfo:");
+  if (msg().level()>=MSG::DEBUG) tagInfo->printTags(msg());
+  
   // check IOVDbSvc GlobalTag, if not already set
   if (m_globalTag=="") {
     tagInfo->findTag("IOVDbGlobalTag",m_globalTag);
-    if (m_globalTag!="")
-      if (m_log->level()<=MSG::INFO) 
-        *m_log << MSG::INFO << "Global tag: " << m_globalTag
-               << " set from input file" << endmsg;
+    if (m_globalTag!="") ATH_MSG_INFO( "Global tag: " << m_globalTag<< " set from input file" );
   }
 
   // now check for tag overrides for specific folders
   TagInfo::NameTagPairVec tags;
   tagInfo->getInputTags(tags);
-  for (TagInfo::NameTagPairVec::const_iterator itr=tags.begin();
-       itr!=tags.end();++itr) {
+  for (TagInfo::NameTagPairVec::const_iterator itr=tags.begin();itr!=tags.end();++itr) {
     // assume tags relating to conditions folders start with /
     if ((itr->first).substr(0,1)!="/") continue;
     // check for folder(s) with this name
-    for (FolderMap::iterator fitr=m_foldermap.begin();fitr!=m_foldermap.end();
-         ++fitr) {
+    for (FolderMap::iterator fitr=m_foldermap.begin();fitr!=m_foldermap.end();++fitr) {
       IOVDbFolder* folder=fitr->second;
       const std::string& ifname=folder->folderName();
       if (ifname!=itr->first) continue; 
@@ -898,20 +819,10 @@ StatusCode IOVDbSvc::processTagInfo(IOVSVC_CALLBACK_ARGS) {
       if (folder->joTag()=="" && !folder->readMeta() && 
           !folder->noOverride() && m_par_globalTag=="") {
         folder->setTagOverride(itr->second,false);
-        if (m_log->level()<=MSG::INFO) 
-          *m_log << MSG::INFO << "TagInfo override for tag " 
-                 << itr->second << " in folder " << ifname << endmsg;
+        ATH_MSG_INFO( "TagInfo override for tag " << itr->second << " in folder " << ifname );
       } else if (folder->joTag()!=itr->second) {
-        if (m_log->level()<=MSG::INFO) {
-          *m_log << MSG::INFO << "Ignoring inputfile TagInfo request for tag "
-                 << itr->second << " in folder " << ifname;
-          if (folder->joTag()=="") {
-            *m_log << " in favour of hierarchical tag" << endmsg;
-          } else {
-            *m_log <<
-              " in favour of jobOption tag " << folder->joTag() << endmsg;
-          }
-        }
+        const std::string tagTypeString=(folder->joTag().empty()) ? "hierarchical" : "jobOption";
+        ATH_MSG_INFO( "Ignoring inputfile TagInfo request for tag " << itr->second << " in folder " << ifname<<" in favour of "<<tagTypeString);
       }
     }
   }
@@ -959,14 +870,11 @@ bool IOVDbSvc::dropObject(const std::string& key, const bool resetCache) {
     SG::DataProxy* proxy=m_h_detStore->proxy(clid,key);
     if (proxy!=0) {
       m_h_detStore->clearProxyPayload(proxy);
-      if (m_log->level()<=MSG::DEBUG) *m_log << MSG::DEBUG << 
-                                        "Dropped payload for key " << key << endmsg;
+      ATH_MSG_DEBUG("Dropped payload for key " << key );
       folder->setDropped(true);
       if (resetCache) {
         folder->resetCache();
-        if (m_log->level()<=MSG::DEBUG) 
-          *m_log << MSG::DEBUG << "Cache reset done for folder " << 
-            folder->folderName() << endmsg;
+        ATH_MSG_DEBUG( "Cache reset done for folder " << folder->folderName() );
       }
       return true;
     } else {
@@ -989,8 +897,8 @@ StatusCode IOVDbSvc::checkEventSel() {
   // access jobOptionSvc and get properties of EventSelector
   ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc",name());
   if (!joSvc.retrieve().isSuccess()) {
-    *m_log << MSG::FATAL << "Could not retrieve [" << joSvc.typeAndName() 
-           << "]" << endmsg;
+    ATH_MSG_FATAL( "Could not retrieve [" << joSvc.typeAndName() 
+           << "]" );
     return StatusCode::FAILURE;
   }
   typedef std::vector<const Property*> Properties_t;
@@ -998,31 +906,26 @@ StatusCode IOVDbSvc::checkEventSel() {
   // do not return FAILURE if the EventSelector cannot be found, as this
   // happens online when we have no EventSelector
   if (0==evtSelProps) {
-    if (m_log->level()<=MSG::DEBUG)     
-      *m_log << MSG::DEBUG
-             << "Could not retrieve properties of 'EventSelector' from ["
-             << joSvc.typeAndName() << "]" << endmsg;
+    ATH_MSG_DEBUG( "Could not retrieve properties of 'EventSelector' from ["<< joSvc.typeAndName() << "]" );
     return StatusCode::SUCCESS;
   }
   BooleanProperty bprop("OverrideRunNumber",false);
   if (StatusCode::SUCCESS==::fetchProp<BooleanProperty>(evtSelProps,bprop)) {
     if (bprop.value()) {
       // if flag is set, extract Run,LB and time
-      *m_log << MSG::INFO << 
-        "Setting run/LB/time from EventSelector override in initialize" << endmsg;
+      ATH_MSG_INFO(  "Setting run/LB/time from EventSelector override in initialize" );
       uint32_t run,lumib;
       uint64_t time;
       bool allGood=true;
       if (m_par_forceRunNumber.value()!=0 || 
           m_par_forceLumiblockNumber.value()!=0)
-        *m_log << MSG::WARNING << "forceRunNumber property also set" << endmsg;
+        ATH_MSG_WARNING( "forceRunNumber property also set" );
       IntegerProperty iprop1("RunNumber",0);
       if (StatusCode::SUCCESS==
           ::fetchProp<IntegerProperty>(evtSelProps,iprop1)) {
         run=iprop1.value();
       } else {
-        *m_log << MSG::ERROR << "Unable to get RunNumber from EventSelector"
-               << endmsg;
+        ATH_MSG_ERROR( "Unable to get RunNumber from EventSelector");
         allGood=false;
       }
       IntegerProperty iprop2("FirstLB",0);
@@ -1030,8 +933,7 @@ StatusCode IOVDbSvc::checkEventSel() {
           ::fetchProp<IntegerProperty>(evtSelProps,iprop2)) {
         lumib=iprop2.value();
       } else {
-        *m_log << MSG::ERROR << "Unable to get FirstLB from EventSelector"
-               << endmsg;
+        ATH_MSG_ERROR( "Unable to get FirstLB from EventSelector");
         allGood=false;
       }
       IntegerProperty iprop3("InitialTimeStamp",0);
@@ -1039,25 +941,22 @@ StatusCode IOVDbSvc::checkEventSel() {
           ::fetchProp<IntegerProperty>(evtSelProps,iprop3)) {
         time=iprop3.value();
       } else {
-        *m_log << MSG::ERROR << 
-          "Unable to get InitialTimeStamp from EventSelector" << endmsg;
+        ATH_MSG_ERROR("Unable to get InitialTimeStamp from EventSelector" );
         allGood=false;
       }
       if (allGood) {
         m_iovTime.setRunEvent(run,lumib);
         uint64_t nsTime=time*1000000000LL;
         m_iovTime.setTimestamp(nsTime);
-        *m_log << MSG::INFO << "run/LB/time set to [" << run << "," << lumib
-               << " : " << nsTime << "]" << endmsg;
+        ATH_MSG_INFO( "run/LB/time set to [" << run << "," << lumib
+               << " : " << nsTime << "]" );
       } else {
-        *m_log << MSG::ERROR << "run/LB/Time NOT changed" << endmsg;
+        ATH_MSG_ERROR( "run/LB/Time NOT changed" );
       }
     }
   } else {
     // this is not treated as an error if EventSelector has no override prop
-    if (m_log->level()<=MSG::DEBUG) 
-      *m_log << MSG::DEBUG << 
-        "Unable to get OverrideRunNumber flag from EventSelector" << endmsg;
+    ATH_MSG_DEBUG("Unable to get OverrideRunNumber flag from EventSelector" );
 
   }
   return StatusCode::SUCCESS;
@@ -1071,8 +970,8 @@ StatusCode IOVDbSvc::setupFolders() {
   std::list<IOVDbParser> allFolderdata;
   for (std::vector<std::string>::const_iterator itr=m_par_folders.begin();
        itr!=m_par_folders.end();++itr) {
-    if (m_log->level()<=MSG::DEBUG) *m_log << MSG::DEBUG << "Setup folder " << *itr << endmsg;
-    IOVDbParser folderdata(*itr,m_log);
+    ATH_MSG_DEBUG( "Setup folder " << *itr );
+    IOVDbParser folderdata(*itr,msg());
     if (!folderdata.isValid()) return StatusCode::FAILURE;
     allFolderdata.push_back(folderdata);
   }
@@ -1085,11 +984,10 @@ StatusCode IOVDbSvc::setupFolders() {
 
   for (std::vector<std::string>::const_iterator titr=m_par_overrideTags.begin();
        titr!=m_par_overrideTags.end();++titr) {
-    IOVDbParser keys(*titr,m_log);
+    IOVDbParser keys(*titr,msg());
     std::string prefix;
     if (!keys.getKey("prefix","",prefix)) { // || !keys.getKey("tag","",tag)) {
-      *m_log << MSG::ERROR << "Problem in overrideTag specification " << 
-        *titr << endmsg;
+      ATH_MSG_ERROR( "Problem in overrideTag specification " <<*titr );
       return StatusCode::FAILURE;
     }
 
@@ -1099,7 +997,7 @@ StatusCode IOVDbSvc::setupFolders() {
           (ifname.size()==prefix.size() || 
            ifname.substr(prefix.size(),1)=="/")) {
         //Match! 
-        folderdata.applyOverrides(keys,m_log);
+        folderdata.applyOverrides(keys,msg());
       }// end if
     }// end loop over allFolderdata
   }// end loop over overrides
@@ -1115,14 +1013,14 @@ StatusCode IOVDbSvc::setupFolders() {
       const IOVDbParser& folder2=*it2;
       if (folder1==folder2) {
         it2=allFolderdata.erase(it2); //FIXME: Smarter distinction/reporting about same folder but different keys.
-        *m_log << MSG::DEBUG << "Removing duplicate folder " << folder1.folderName() << endmsg;
+        ATH_MSG_DEBUG( "Removing duplicate folder " << folder1.folderName());
       } 
       else {
         ++it2;
         //Catch suspicous cases:
         if (folder1.folderName()==folder2.folderName()) {
-          *m_log << MSG::WARNING << "Folder name appears twice: " << folder1.folderName() << endmsg;
-          *m_log << MSG::WARNING << folder1 << " vs " << folder2 << endmsg;
+          ATH_MSG_WARNING( "Folder name appears twice: " << folder1.folderName() );
+          ATH_MSG_WARNING( folder1 << " vs " << folder2 );
         }
       }
     }//end inner loop
@@ -1149,7 +1047,7 @@ StatusCode IOVDbSvc::setupFolders() {
       }
       if (conn==0) {
         // create new read-onlyconnection
-        conn=new IOVDbConn(connstr,true,m_log);
+        conn=new IOVDbConn(connstr,true,msg());
         m_connections.push_back(conn);
       }
     } else {
@@ -1157,23 +1055,23 @@ StatusCode IOVDbSvc::setupFolders() {
       if (m_par_defaultConnection!="") {
         conn=m_connections[0];
       } else {
-        *m_log << MSG::FATAL << "Folder request " << folderdata.folderName() << 
-          " gives no DB connection information and no default set" << endmsg;
+        ATH_MSG_FATAL( "Folder request " << folderdata.folderName() << 
+          " gives no DB connection information and no default set" );
         return StatusCode::FAILURE;
       }
     }
     // create the new folder, but only if a folder for this SG key has not
     // already been requested
-    IOVDbFolder* folder=new IOVDbFolder(conn,folderdata,m_log,&(*m_h_clidSvc),
+    IOVDbFolder* folder=new IOVDbFolder(conn,folderdata,msg(),&(*m_h_clidSvc),
                                         m_par_checklock);
     const std::string& key=folder->key();
     if (m_foldermap.find(key)==m_foldermap.end()) {  //This check is too weak. For POOL-based folders, the SG key is in the folder description (not known at this point).
       m_foldermap[key]=folder;
       conn->incUsage();
     } else {
-      *m_log << MSG::ERROR << "Duplicate request for folder " << 
+      ATH_MSG_ERROR( "Duplicate request for folder " << 
         folder->folderName() << 
-        " associated to already requested Storegate key " << key << endmsg;
+        " associated to already requested Storegate key " << key );
       // clean up this duplicate request
       delete folder;
     }
@@ -1192,8 +1090,8 @@ StatusCode IOVDbSvc::setupFolders() {
       IOVDbFolder* fptr=fitr->second;
       if ((fptr->folderName()).substr(0,match.size())==match) {
         fptr->setWriteMeta(&(*m_h_metaDataTool));
-        *m_log << MSG::INFO << "Folder " << fptr->folderName() << 
-          " will be written to file metadata" << endmsg;
+        ATH_MSG_INFO( "Folder " << fptr->folderName() << 
+          " will be written to file metadata" );
       }
     }//end loop over FolderMap
   }//end loop over  m_par_foldersToWrite
@@ -1202,9 +1100,7 @@ StatusCode IOVDbSvc::setupFolders() {
 
 StatusCode IOVDbSvc::fillTagInfo() {
   if (m_par_globalTag!="") {
-    if (m_log->level()<=MSG::DEBUG)     
-      *m_log << MSG::DEBUG << "Adding GlobalTag " << m_par_globalTag << 
-        " into TagInfo" << endmsg;
+    ATH_MSG_DEBUG( "Adding GlobalTag " << m_par_globalTag << " into TagInfo" );
     if (StatusCode::SUCCESS!=m_h_tagInfoMgr->addTag("IOVDbGlobalTag",
                                                     m_par_globalTag))
       return StatusCode::FAILURE;
@@ -1215,9 +1111,7 @@ StatusCode IOVDbSvc::fillTagInfo() {
        fitr!=m_foldermap.end();++fitr) {
     const IOVDbFolder* folder=fitr->second;
     if (folder->joTag()!="") {
-      if (m_log->level()<=MSG::DEBUG) 
-        *m_log << MSG::DEBUG << "Adding folder " << folder->folderName() <<
-          " tag " << folder->joTag() << " into TagInfo" << endmsg;
+      ATH_MSG_DEBUG( "Adding folder " << folder->folderName() <<" tag " << folder->joTag() << " into TagInfo" );
       if (StatusCode::SUCCESS!=m_h_tagInfoMgr->addTag(folder->folderName(),
                                                       folder->joTag()))
         return StatusCode::FAILURE;
@@ -1231,11 +1125,11 @@ StatusCode IOVDbSvc::fillTagInfo() {
         folder->readMeta()) {
       if (StatusCode::SUCCESS!=
           m_h_tagInfoMgr->removeTagFromInput(folder->folderName())) {
-        *m_log << MSG::WARNING << "Could not add TagInfo remove request for "
-               << folder->folderName() << endmsg;
+        ATH_MSG_WARNING( "Could not add TagInfo remove request for "
+               << folder->folderName() );
       } else {
-        *m_log << MSG::INFO << "Added taginfo remove for " << 
-          folder->folderName() << endmsg;
+        ATH_MSG_INFO( "Added taginfo remove for " << 
+          folder->folderName() );
       }
     }
   }
@@ -1248,9 +1142,7 @@ StatusCode IOVDbSvc::loadCaches(IOVDbConn* conn, const IOVTime* time) {
 
   Gaudi::Guards::AuditorGuard auditor(std::string("loadCachesOverhead:")+conn->name(), auditorSvc(), "preLoadProxy");
 
-  if (m_log->level()<=MSG::DEBUG) 
-    *m_log << MSG::DEBUG << "loadCaches: Begin for connection " << conn->name() 
-           << endmsg;
+  ATH_MSG_DEBUG( "loadCaches: Begin for connection " << conn->name());
   // if global abort already set, load nothing
   if (m_abort) return StatusCode::FAILURE;
   bool access=false;
@@ -1262,8 +1154,8 @@ StatusCode IOVDbSvc::loadCaches(IOVDbConn* conn, const IOVTime* time) {
     cool::ValidityKey vkey=folder->iovTime(time==nullptr ? m_iovTime : *time);
     // protect against out of range times (timestamp -1 happened in FDR2)
     if (vkey>cool::ValidityKeyMax) {
-      *m_log << MSG::WARNING << "Requested validity key " << vkey << 
-        " is out of range, reset to 0" << endmsg;
+      ATH_MSG_WARNING( "Requested validity key " << vkey << 
+        " is out of range, reset to 0" );
       vkey=0;
     }
     if (!folder->cacheValid(vkey) && !folder->dropped()) {
@@ -1271,8 +1163,8 @@ StatusCode IOVDbSvc::loadCaches(IOVDbConn* conn, const IOVTime* time) {
       {
         Gaudi::Guards::AuditorGuard auditor(std::string("FldrCache:")+folder->folderName(), auditorSvc(), "preLoadProxy");
         if (!folder->loadCache(vkey,m_par_cacheAlign,m_globalTag,m_par_onlineMode)) {
-          *m_log << MSG::ERROR << "Cache load (prefetch) failed for folder " << 
-            folder->folderName() << endmsg;
+          ATH_MSG_ERROR( "Cache load (prefetch) failed for folder " << 
+            folder->folderName() );
           // remember the failure, but also load other folders on this connection
           // while it is open
           sc=StatusCode::FAILURE;
@@ -1285,37 +1177,35 @@ StatusCode IOVDbSvc::loadCaches(IOVDbConn* conn, const IOVTime* time) {
   // if connection aborted, set overall abort so we do not waste time trying
   // to read data from other schema
   if (conn->aborted()) {
-    *m_log << MSG::FATAL << "Connection " << conn->name() << 
-      " was aborted, set global abort" << endmsg;
+    ATH_MSG_FATAL( "Connection " << conn->name() << 
+      " was aborted, set global abort" );
     m_abort=true;
-    *m_log << MSG::FATAL << "loadCache: impossible to load cache!" << endmsg; 
+    ATH_MSG_FATAL( "loadCache: impossible to load cache!" ); 
     throw std::exception();
   }
   return sc;
 }
 
 void IOVDbSvc::printMetaDataContainer(const IOVMetaDataContainer* cont) {
-  if (m_log->level()>MSG::DEBUG)
+  if (msg().level()>MSG::DEBUG)
     return;
   // Print out the contents of a meta data container (in debug mode)
-  *m_log << MSG::DEBUG << "printMetaDataContainer " << endmsg;
-  *m_log << MSG::DEBUG << "Folder name " << cont->folderName() << endmsg;
-  *m_log << MSG::DEBUG << "Description " << cont->folderDescription() << endmsg;
+  ATH_MSG_DEBUG( "printMetaDataContainer " );
+  ATH_MSG_DEBUG( "Folder name " << cont->folderName() );
+  ATH_MSG_DEBUG( "Description " << cont->folderDescription() );
   // Print out contents of payload
   const IOVPayloadContainer*  payload=cont->payloadContainer();
   // print out iovs and attribute lists
-  *m_log << MSG::DEBUG << "payload size " << payload->size() << endmsg;
-  *m_log << MSG::DEBUG << "IOVs and attribute lists: " << endmsg;
+  ATH_MSG_DEBUG( "payload size " << payload->size() );
+  ATH_MSG_DEBUG( "IOVs and attribute lists: " );
   IOVPayloadContainer::const_iterator itAttList=payload->begin();
   IOVPayloadContainer::const_iterator itAttListEnd=payload->end();
   for (;itAttList!=itAttListEnd;++itAttList) {
-    *m_log << MSG::DEBUG << (*itAttList)->minRange() << " iov size " 
-           << (*itAttList)->iov_size() << endmsg;
+    ATH_MSG_DEBUG( (*itAttList)->minRange() << " iov size " << (*itAttList)->iov_size() );
     CondAttrListCollection::iov_const_iterator itIOV=(*itAttList)->iov_begin();
     CondAttrListCollection::iov_const_iterator itIOVEnd=(*itAttList)->iov_end();
     for (;itIOV!=itIOVEnd; ++itIOV) 
-      *m_log << MSG::DEBUG << (*itIOV).first << " " << (*itIOV).second << 
-        endmsg;
+      ATH_MSG_DEBUG( (*itIOV).first << " " << (*itIOV).second );
     CondAttrListCollection::const_iterator itAtt=(*itAttList)->begin();
     CondAttrListCollection::const_iterator itAttEnd=(*itAttList)->end();
     for (;itAtt!=itAttEnd;++itAtt) {
@@ -1327,18 +1217,16 @@ void IOVDbSvc::printMetaDataContainer(const IOVMetaDataContainer* cont) {
         itr->toOutputStream(attrStr);
       }
       attrStr << "}";
-      *m_log << MSG::DEBUG << (*itAtt).first << " " << attrStr.str() << endmsg;
+      ATH_MSG_DEBUG( (*itAtt).first << " " << attrStr.str() );
     }
   }
 }
 
 void IOVDbSvc::dumpKeys() {
   // use the getKeyList and getKeyInfo methods to dump all keys in event
-  *m_log << MSG::INFO << "Dump IOVDbSvc-managed SG keys for first event" 
-         << endmsg;
+  ATH_MSG_INFO( "Dump IOVDbSvc-managed SG keys for first event" );
   std::vector<std::string> keys=getKeyList();
-  *m_log << MSG::INFO << "Total of " << keys.size() << " keys to list" << 
-    endmsg;
+  ATH_MSG_INFO( "Total of " << keys.size() << " keys to list" );
   for (std::vector<std::string>::const_iterator kitr=keys.begin();
        kitr!=keys.end();++kitr) {
     std::string foldername,tag;
@@ -1348,15 +1236,15 @@ void IOVDbSvc::dumpKeys() {
     float rtime;
     if (getKeyInfo(*kitr,foldername,tag,range,retrieved,nread,rtime)) {
       if (retrieved) {
-        *m_log << MSG::INFO << "Data for key " << *kitr << " : foldername " <<
+        ATH_MSG_INFO( "Data for key " << *kitr << " : foldername " <<
           foldername << ", tag" << tag << ", range " << range << 
-          " read " << nread << " bytes in " << rtime << " seconds" << endmsg;
+          " read " << nread << " bytes in " << rtime << " seconds" );
       } else {
-        *m_log << MSG::INFO << "Key " << *kitr << 
-          " was not yet retrieved from StoreGate" << endmsg;
+        ATH_MSG_INFO( "Key " << *kitr << 
+          " was not yet retrieved from StoreGate" );
       }
     } else {
-      *m_log << MSG::ERROR << "No data for key " << *kitr << endmsg;
+      ATH_MSG_ERROR( "No data for key " << *kitr );
     }
   }
 }
diff --git a/Database/IOVDbSvc/src/IOVDbSvc.h b/Database/IOVDbSvc/src/IOVDbSvc.h
index ed34bed94c810a1613d0b185c01adbf3ed9fbe0f..525092dd95bfee86d03735e04f14dfabc797bb76 100644
--- a/Database/IOVDbSvc/src/IOVDbSvc.h
+++ b/Database/IOVDbSvc/src/IOVDbSvc.h
@@ -38,6 +38,10 @@
 
 #include "IOVDbConn.h"
 
+//for using the msg service
+	//#include "AthenaKernel/MsgStreamMember.h"
+	//#include "AthenaBaseComps/AthMsgStreamMacros.h"
+
 
 #include <string>
 #include <vector>
@@ -242,7 +246,7 @@ private:
   ToolHandle<IIOVDbMetaDataTool> m_h_metaDataTool;
   ServiceHandle<ITagInfoMgr>     m_h_tagInfoMgr;
   // message stream
-  MsgStream* m_log;
+  //MsgStream* m_log;
         
   // Flag to signal when a pool payload has been requested. This
   // implies that a pool file has been open during an event, and will
@@ -283,6 +287,23 @@ private:
   FolderMap m_foldermap;
   // gloal abort flag
   bool m_abort;
+  
+  protected:
+   /// Log a message using the Athena controlled logging system
+   /**
+          MsgStream&
+          msg(MSG::Level lvl) const {
+            return m_msg.get() << lvl;
+          }
+       
+          /// Check whether the logging system is active at the provided verbosity level
+          bool
+          msgLvl(MSG::Level lvl) {
+            return m_msg.get().level() <= lvl;
+          }
+       
+          /// Private message stream member
+          mutable Athena::MsgStreamMember m_msg;**/
 
 };