diff --git a/DDCond/src/ConditionsRepository.cpp b/DDCond/src/ConditionsRepository.cpp
index ed521879e7371c6e6de554e027684a28a6ef2527..a248a7bbbe61ed194f446f036c3fd10cc2b4600a 100644
--- a/DDCond/src/ConditionsRepository.cpp
+++ b/DDCond/src/ConditionsRepository.cpp
@@ -164,10 +164,14 @@ namespace {
       in.getline(text,sizeof(text),'\n');
       if ( in.good() )  {
         if ( siz_tot )  {
+	  text[8] = 0;
           // Direct access mode with fixed record size
-          if ( 10+siz_nam+siz_add < (long)sizeof(text) )  {
-            text[8] = text[9+siz_nam] = text[10+siz_nam+siz_add] = 0;
+          if ( 9+siz_nam < (long)sizeof(text) )  {
+            text[9+siz_nam] = 0;
             e.name = text+9;
+	  }
+          if ( 10+siz_nam+siz_add < (long)sizeof(text) )  {
+            text[10+siz_nam+siz_add] = 0;
             e.address = text+10+siz_nam;  
             if ( (idx=e.name.find(' ')) != string::npos && idx < e.name.length() )
               e.name[idx] = 0;
@@ -181,7 +185,7 @@ namespace {
         else  {
           // Variable record size
           e.name=text+9;
-          if ( (idx=e.name.find(sep)) != string::npos && idx < sizeof(text)-9 )
+          if ( (idx=e.name.find(sep)) != string::npos && idx < sizeof(text)-10 )
             text[9+idx] = 0, e.address=text+idx+10, e.name=text+9;
           if ( (idx=e.address.find(sep)) != string::npos && idx < e.address.length() )
             e.address[idx] = 0;
diff --git a/DDCond/src/Type1/Manager_Type1.cpp b/DDCond/src/Type1/Manager_Type1.cpp
index a4491d75143696ed715982887a996970bbefccf7..5b5081e466189d664b89665870365e61c01d2ade 100644
--- a/DDCond/src/Type1/Manager_Type1.cpp
+++ b/DDCond/src/Type1/Manager_Type1.cpp
@@ -399,8 +399,9 @@ void Manager_Type1::pushUpdates()   {
     if ( !ents.empty() )  {
       for(Condition c : ents )  {
         c->setFlag(Condition::ACTIVE);
-        /// FIXME!
-        throw runtime_error("FIXME!!!");
+	except("ConditionsMgr",
+	       "+++ We should never end up here [%s]. FIXME!!!!",
+	       c.str(0).c_str());
         //c->pool->insert(c);
       }
     }
diff --git a/DDCore/include/DD4hep/DetectorImp.h b/DDCore/include/DD4hep/DetectorImp.h
index ca3d4f16caee070338ed64e5d027438aea2a3960..82ee08b2b11f16b95e2383623bccceb5dcf563cd 100644
--- a/DDCore/include/DD4hep/DetectorImp.h
+++ b/DDCore/include/DD4hep/DetectorImp.h
@@ -71,7 +71,7 @@ namespace dd4hep {
     DetectorBuildType m_buildType;
 
     /// Optical surface manager
-    detail::OpticalSurfaceManagerObject* m_surfaceManager = 0;   //! not persistent
+    detail::OpticalSurfaceManagerObject* m_surfaceManager {nullptr};   //! not persistent
 
   private:
     /// Disable move constructor
diff --git a/DDCore/include/DD4hep/Handle.h b/DDCore/include/DD4hep/Handle.h
index 1ece25da3cfb271cd3a7ac2a6b185eb8c15bb77c..61c019a27a84e369129f388f3062bb23114c7b5d 100644
--- a/DDCore/include/DD4hep/Handle.h
+++ b/DDCore/include/DD4hep/Handle.h
@@ -90,7 +90,7 @@ namespace dd4hep {
     typedef Handle<T> Base;
     
     /// Single and only data member: Reference to the actual element.
-    T* m_element = 0;
+    T* m_element  {nullptr};
 
     /// Default constructor
     Handle() = default;
diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp
index 2f4adc73cd7fd0636b026ff69f08a20b78551bd9..b744bd69cfc97ded6eaa56366b5a6fd35bef0c99 100644
--- a/DDCore/src/DetectorImp.cpp
+++ b/DDCore/src/DetectorImp.cpp
@@ -158,6 +158,7 @@ void Detector::destroyInstance(const std::string& name) {
 DetectorImp::DetectorImp()
   : TNamed(), DetectorData(), DetectorLoad(this), m_buildType(BUILD_NONE)
 {
+  m_surfaceManager = new detail::OpticalSurfaceManagerObject(*this);
   m_std_conditions.convention  = STD_Conditions::NTP;
   m_std_conditions.pressure    = Pressure_NTP;
   m_std_conditions.temperature = Temperature_NTP;
@@ -241,9 +242,13 @@ DetectorImp::~DetectorImp() {
       detector_instances().remove(m_manager->GetName());
     }
   }
-  deletePtr(m_surfaceManager);
+  if ( m_surfaceManager )   {
+    delete m_surfaceManager;
+    m_surfaceManager = nullptr;
+  }
   destroyData(false);
   m_extensions.clear();
+  m_detectorTypes.clear();
   InstanceCount::decrement(this);
 }
 
diff --git a/DDCore/src/Plugins.cpp b/DDCore/src/Plugins.cpp
index d1c04044e08674b3435bb7daba23416f2ff00878..12ec54b765d04f015bccf5819ffa5a272ad67cbc 100644
--- a/DDCore/src/Plugins.cpp
+++ b/DDCore/src/Plugins.cpp
@@ -105,6 +105,14 @@ namespace   {
 #endif
 #if defined(DD4HEP_PARSERS_NO_ROOT)
     handle = ::dlopen(plugin_name, RTLD_LAZY | RTLD_GLOBAL);
+    if ( handle )   {
+      struct handle_guard  {
+	void* _handle {nullptr};
+	handle_guard(void* hdl) : _handle(hdl) {}
+	~handle_guard()  { if ( _handle ) ::dlclose(_handle); _handle = nullptr; }
+      };
+      static handle_guard _guard(handle);
+    }
 #else
     if ( 0 != gSystem->Load(plugin_name) ) {}
 #endif
diff --git a/DDG4/include/DDG4/Geant4Action.h b/DDG4/include/DDG4/Geant4Action.h
index 29e074bcf919eef3da40ec0083ebeb3ac042fef6..a4bdcdf5b22dbd1b3b73ffe4a7d7e7c2f363a9ea 100644
--- a/DDG4/include/DDG4/Geant4Action.h
+++ b/DDG4/include/DDG4/Geant4Action.h
@@ -111,20 +111,20 @@ namespace dd4hep {
     class Geant4Action {
     protected:
       /// Reference to the Geant4 context
-      Geant4Context*     m_context = 0;
+      Geant4Context*     m_context  {nullptr};
       /// Control directory of this action
-      Geant4UIMessenger* m_control = 0;
+      Geant4UIMessenger* m_control  {nullptr};
 
       /// Default property: Output level
-      int                m_outputLevel = 3;
+      int                m_outputLevel  {3};
       /// Default property: Flag to create control instance
-      bool               m_needsControl = false;
+      bool               m_needsControl {false};
       /// Action name
       std::string        m_name;
       /// Property pool
       PropertyManager    m_properties;
       /// Reference count. Initial value: 1
-      long               m_refCount = 1;
+      long               m_refCount     {1};
 
     public:
       /// Functor to update the context of a Geant4Action object
@@ -135,8 +135,8 @@ namespace dd4hep {
        */
       class ContextSwap   {
         /// reference to the context;
-        Geant4Context* context = 0;
-        Geant4Action*  action = 0;
+        Geant4Context* context {nullptr};
+        Geant4Action*  action  {nullptr};
       public:
         /// Constructor
         ContextSwap(Geant4Action* a,Geant4Context* c) : action(a)  {
diff --git a/DDG4/include/DDG4/Geant4Handle.h b/DDG4/include/DDG4/Geant4Handle.h
index 27d85d8e02c97ab013a15caccf1dfad6b0a52968..9386354e636c1e322be4a8f2494258e2dc82f046 100644
--- a/DDG4/include/DDG4/Geant4Handle.h
+++ b/DDG4/include/DDG4/Geant4Handle.h
@@ -41,10 +41,10 @@ namespace dd4hep {
     template <typename TYPE> class Geant4Handle {
     protected:
       void checked_assign(TYPE* p);
-      TYPE* null()  { return 0; }
+      TYPE* null()  { return nullptr; }
     public:
       /// Pointer to referenced object
-      mutable TYPE* value = 0;
+      mutable TYPE* value  {nullptr};
       /// Default constructor
       explicit Geant4Handle() = default;
       /// Construction initialized with object pointer
@@ -96,7 +96,7 @@ namespace dd4hep {
     class KernelHandle {
     public:
       /// Pointer to referenced object
-      mutable Geant4Kernel* value;
+      mutable Geant4Kernel* value {nullptr};
       /// Default constructor
       explicit KernelHandle();
       /// Construction initialized with object pointer
diff --git a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp
index ddfaead020c252031d87e4e4a409e9ff79f6937c..ac83e679c600dd9cf19cb5ca29ee3fc0a1ebec1d 100644
--- a/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp
+++ b/DDG4/plugins/Geant4DetectorGeometryConstruction.cpp
@@ -249,21 +249,23 @@ int Geant4DetectorGeometryConstruction::printVolumeObj(const char* vol_path, Pla
       Solid sh  = pv.volume().solid();
       if ( flg )  {
 	printP2("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-	printP2(  "+++  Dump of GEANT4 solid: %s", vol_path);
+	printP2("+++  Dump of GEANT4 solid: %s", vol_path);
       }
+      stringstream output;
       if ( flg )   {
-	cout << mat;
+	output << mat;
 	if ( ion )   {
-	  cout << "          MEE:  ";
-	  cout << setprecision(12);
-	  cout << ion->GetMeanExcitationEnergy()/CLHEP::eV;
-	  cout << " [eV]";
+	  output << "          MEE:  ";
+	  output << setprecision(12);
+	  output << ion->GetMeanExcitationEnergy()/CLHEP::eV;
+	  output << " [eV]";
 	}
 	else
-	  cout << "          MEE: UNKNOWN";
+	  output << "          MEE: UNKNOWN";
       }
       if ( flg )   {
-	cout << endl << *sol;
+	output << endl << *sol;
+	printP2("%s", output.str().c_str());
 	printP2("+++  Dump of ROOT   solid: %s", vol_path);
 	sh->InspectShape();
 	if ( sh->IsA() == TGeoScaledShape::Class() )    {
diff --git a/DDG4/plugins/Geant4EventReaderHepMC.cpp b/DDG4/plugins/Geant4EventReaderHepMC.cpp
index 634d8f8b9bf3e6f562b0a0dcbc8aba8fe8d97cab..8c7c3fe93364730aa90b8c32824ad3c2cdba5b11 100644
--- a/DDG4/plugins/Geant4EventReaderHepMC.cpp
+++ b/DDG4/plugins/Geant4EventReaderHepMC.cpp
@@ -480,7 +480,8 @@ int HepMC::read_particle(EventStream &info, istringstream& input, Geant4Particle
   /// Keep a copy of the full generator status
   p->genStatus = stat&G4PARTICLE_GEN_STATUS_MASK;
   
-  // read flow patterns if any exist
+  // read flow patterns if any exist. Protect against tainted readings.
+  size = min(size,100);
   for (int i = 0; i < size; ++i ) {
     input >> p->colorFlow[0] >> p->colorFlow[1];
     if(!input) return 0;
diff --git a/DDG4/src/Geant4Handle.cpp b/DDG4/src/Geant4Handle.cpp
index 4e8cf1c54d24dc206bc4eca5b53fa9fc98d5b272..caaac4956b9511e38d6987822b65d68f5b1f6d9c 100644
--- a/DDG4/src/Geant4Handle.cpp
+++ b/DDG4/src/Geant4Handle.cpp
@@ -239,80 +239,80 @@ namespace dd4hep {
 
     template <> 
     Geant4Handle<Geant4RunAction>::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::runAction,type_name,
-                            "Geant4SharedRunAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::runAction, type_name,
+                            "Geant4SharedRunAction", shared, null());
     }
     template <> 
     Geant4Handle<Geant4RunAction>::Geant4Handle(Geant4Kernel& kernel, const char* type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::runAction,type_name,
-                            "Geant4SharedRunAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::runAction, type_name,
+                            "Geant4SharedRunAction", shared, null());
     }
 
     template <> 
     Geant4Handle<Geant4EventAction>::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::eventAction,type_name,
-                            "Geant4SharedEventAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::eventAction, type_name,
+                            "Geant4SharedEventAction", shared, null());
     }
     template <> 
     Geant4Handle<Geant4EventAction>::Geant4Handle(Geant4Kernel& kernel, const char* type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::eventAction,type_name,
-                            "Geant4SharedEventAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::eventAction, type_name,
+                            "Geant4SharedEventAction", shared, null());
     }
 
     template <> 
     Geant4Handle<Geant4GeneratorAction>::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::generatorAction,type_name,
-                            "Geant4SharedGeneratorAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::generatorAction, type_name,
+                            "Geant4SharedGeneratorAction", shared, null());
     }
     template <> 
     Geant4Handle<Geant4GeneratorAction>::Geant4Handle(Geant4Kernel& kernel, const char* type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::generatorAction,type_name,
-                            "Geant4SharedGeneratorAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::generatorAction, type_name,
+                            "Geant4SharedGeneratorAction", shared, null());
     }
 
     template <> 
     Geant4Handle<Geant4TrackingAction>::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::trackingAction,type_name,
-                            "Geant4SharedTrackingAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::trackingAction, type_name,
+                            "Geant4SharedTrackingAction", shared, null());
     }
     template <> 
     Geant4Handle<Geant4TrackingAction>::Geant4Handle(Geant4Kernel& kernel, const char* type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::trackingAction,type_name,
-                            "Geant4SharedTrackingAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::trackingAction, type_name,
+                            "Geant4SharedTrackingAction", shared, null());
     }
 
     template <> 
     Geant4Handle<Geant4SteppingAction>::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::steppingAction,type_name,
-                            "Geant4SharedSteppingAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::steppingAction, type_name,
+                            "Geant4SharedSteppingAction", shared, null());
     }
     template <> 
     Geant4Handle<Geant4SteppingAction>::Geant4Handle(Geant4Kernel& kernel, const char* type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::steppingAction,type_name,
-                            "Geant4SharedSteppingAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::steppingAction, type_name,
+                            "Geant4SharedSteppingAction", shared, null());
     }
 
     template <> 
     Geant4Handle<Geant4StackingAction>::Geant4Handle(Geant4Kernel& kernel, const string& type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::stackingAction,type_name,
-                            "Geant4SharedStackingAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::stackingAction, type_name,
+                            "Geant4SharedStackingAction", shared, null());
     }
     template <> 
     Geant4Handle<Geant4StackingAction>::Geant4Handle(Geant4Kernel& kernel, const char* type_name, bool shared)  {
-      value = _create_share(kernel,&Geant4ActionContainer::stackingAction,type_name,
-                            "Geant4SharedStackingAction",shared,null());
+      value = _create_share(kernel,&Geant4ActionContainer::stackingAction, type_name,
+                            "Geant4SharedStackingAction", shared, null());
     }
 
     template <> Geant4Handle<Geant4Sensitive>::Geant4Handle(Geant4Kernel& kernel, const string& type_name,
                                                             const string& detector, bool /* shared */) {
       try {
-        Geant4Context* ctxt = kernel.workerContext();
-        TypeName typ = TypeName::split(type_name);
-        Detector& description = kernel.detectorDescription();
-        DetElement det = description.detector(detector);
-        Geant4Sensitive* object = PluginService::Create<Geant4Sensitive*>(typ.first, ctxt, typ.second, &det, &description);
-        if (object) {
-          value = object;
+        Geant4Context*  ctxt = kernel.workerContext();
+        TypeName         typ = TypeName::split(type_name);
+        Detector&        dsc = kernel.detectorDescription();
+        DetElement       det = dsc.detector(detector);
+        Geant4Sensitive* obj = PluginService::Create<Geant4Sensitive*>(typ.first, ctxt, typ.second, &det, &dsc);
+        if ( obj ) {
+          value = obj;
           return;
         }
       }