diff --git a/source/RobotAPI/components/ArViz/Client/drawer/ArVizDrawerBase.cpp b/source/RobotAPI/components/ArViz/Client/drawer/ArVizDrawerBase.cpp
index a19032cd088ccdf49e16af5ea394d73a92b30878..9d2c8e7ed36b6a494556ecdd55e652aea93b7e77 100644
--- a/source/RobotAPI/components/ArViz/Client/drawer/ArVizDrawerBase.cpp
+++ b/source/RobotAPI/components/ArViz/Client/drawer/ArVizDrawerBase.cpp
@@ -6,21 +6,27 @@
 namespace armarx
 {
 
-    ArVizDrawerBase::ArVizDrawerBase(armarx::viz::Client &arviz) : arvizClient(arviz) {}
+    ArVizDrawerBase::ArVizDrawerBase(armarx::viz::Client& arviz) : arvizClient(arviz) {}
 
     ArVizDrawerBase::~ArVizDrawerBase() = default;
 
-    viz::Client &ArVizDrawerBase::arviz() { return arvizClient; }
+    viz::ScopedClient& ArVizDrawerBase::arviz()
+    {
+        return arvizClient;
+    }
 
-    const viz::Client &ArVizDrawerBase::arviz() const { return arvizClient; }
+    const viz::ScopedClient& ArVizDrawerBase::arviz() const
+    {
+        return arvizClient;
+    }
 
-    void ArVizDrawerBase::commit(const viz::Layer &layer)
+    void ArVizDrawerBase::commit(const viz::Layer& layer)
     {
         std::lock_guard guard{layerMtx};
         arvizClient.commit(layer);
     }
 
-    void ArVizDrawerBase::commit(const std::vector<viz::Layer> &layers)
+    void ArVizDrawerBase::commit(const std::vector<viz::Layer>& layers)
     {
         std::lock_guard guard{layerMtx};
         arvizClient.commit(layers);
diff --git a/source/RobotAPI/components/ArViz/Client/drawer/ArVizDrawerBase.h b/source/RobotAPI/components/ArViz/Client/drawer/ArVizDrawerBase.h
index f7c813be72283ec4899f402a1133c41ab5a381e2..e302acc5c27e025aac9c103793f7a5ed726d76d9 100644
--- a/source/RobotAPI/components/ArViz/Client/drawer/ArVizDrawerBase.h
+++ b/source/RobotAPI/components/ArViz/Client/drawer/ArVizDrawerBase.h
@@ -24,6 +24,8 @@
 #include <mutex>
 #include <vector>
 
+#include "RobotAPI/components/ArViz/Client/ScopedClient.h"
+
 namespace armarx
 {
     // forward declaration
@@ -42,19 +44,19 @@ namespace armarx
      */
     class ArVizDrawerBase
     {
-      public:
-        ArVizDrawerBase(armarx::viz::Client &arviz);
+    public:
+        ArVizDrawerBase(armarx::viz::Client& arviz);
         virtual ~ArVizDrawerBase();
 
-      protected:
-        viz::Client &arviz();
-        const viz::Client &arviz() const;
+    protected:
+        viz::ScopedClient& arviz();
+        const viz::ScopedClient& arviz() const;
 
-        void commit(const viz::Layer &layer);
-        void commit(const std::vector<viz::Layer> &layers);
+        void commit(const viz::Layer& layer);
+        void commit(const std::vector<viz::Layer>& layers);
 
-      private:
-        viz::Client &arvizClient;
+    private:
+        viz::ScopedClient arvizClient;
 
         std::mutex layerMtx;
     };
diff --git a/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h b/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h
index eefb1b5ce73fdc3f83b5f15101ad3e10e9f0f989..6dc77c57625b0a8ebd33200885f06045eef49bbf 100644
--- a/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h
+++ b/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h
@@ -85,13 +85,13 @@ namespace armarx::armem::base
         }
 
 
-        inline const std::map<std::string, ProviderSegmentT>& providerSegments() const
+        inline const auto& providerSegments() const
         {
             return this->_container;
         }
-        inline std::map<std::string, ProviderSegmentT>& providerSegments()
+        inline auto& providerSegments()
         {
-            return const_cast<std::map<std::string, ProviderSegmentT>&>(const_cast<const CoreSegmentBase*>(this)->providerSegments());
+            return this->_container;
         }
 
 
@@ -197,7 +197,7 @@ namespace armarx::armem::base
                 }
                 else
                 {
-                    auto wms = this->_container.emplace(std::make_pair(k, this->id().withProviderSegmentName(k)));
+                    auto wms = this->_container.emplace(k, this->id().withProviderSegmentName(k));
                     wms.first->second.append(s);
                 }
             }
diff --git a/source/RobotAPI/libraries/armem/core/base/MemoryBase.h b/source/RobotAPI/libraries/armem/core/base/MemoryBase.h
index 69cd01fc128338e3d251a2ca99e54849c962dc9e..d7c8b8cd203fc8b140cbed0b959110f0868a4b83 100644
--- a/source/RobotAPI/libraries/armem/core/base/MemoryBase.h
+++ b/source/RobotAPI/libraries/armem/core/base/MemoryBase.h
@@ -82,13 +82,13 @@ namespace armarx::armem::base
         }
 
 
-        inline const std::map<std::string, CoreSegmentT>& coreSegments() const
+        inline auto& coreSegments() const
         {
             return this->_container;
         }
-        inline std::map<std::string, CoreSegmentT>& coreSegments()
+        inline auto& coreSegments()
         {
-            return const_cast<std::map<std::string, CoreSegmentT>&>(const_cast<const MemoryBase*>(this)->coreSegments());
+            return this->_container;
         }
 
 
@@ -272,7 +272,7 @@ namespace armarx::armem::base
                 }
                 else
                 {
-                    auto wms = this->_container.emplace(std::make_pair(k, this->id().withCoreSegmentName(k)));
+                    auto wms = this->_container.emplace(k, this->id().withCoreSegmentName(k));
                     wms.first->second.append(s);
                 }
             }
diff --git a/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h b/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h
index a53595c8784ea64cc4994f3f77b4ac22a1510cb1..57ff3210244fa516551f4906a2ea07c2cc81f09d 100644
--- a/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h
+++ b/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h
@@ -83,13 +83,13 @@ namespace armarx::armem::base
         }
 
 
-        inline const std::map<std::string, EntityT>& entities() const
+        inline const auto& entities() const
         {
             return this->_container;
         }
-        inline std::map<std::string, EntityT>& entities()
+        inline auto& entities()
         {
-            return const_cast<std::map<std::string, EntityT>&>(const_cast<const ProviderSegmentBase*>(this)->entities());
+            return this->_container;
         }
 
 
@@ -181,7 +181,7 @@ namespace armarx::armem::base
                 }
                 else
                 {
-                    auto wms = this->_container.emplace(std::make_pair(k, this->id().withEntityName(k)));
+                    auto wms = this->_container.emplace(k, this->id().withEntityName(k));
                     wms.first->second.append(s);
                 }
             }
diff --git a/source/RobotAPI/libraries/armem/core/diskmemory/CoreSegment.cpp b/source/RobotAPI/libraries/armem/core/diskmemory/CoreSegment.cpp
index 6a26be9c7915a54b081e5d03b4f67cb6ae9eeaee..dd25b0219a6e0b7559c875ab98446d86ec3fa60f 100644
--- a/source/RobotAPI/libraries/armem/core/diskmemory/CoreSegment.cpp
+++ b/source/RobotAPI/libraries/armem/core/diskmemory/CoreSegment.cpp
@@ -58,7 +58,7 @@ namespace armarx::armem::d_ltm
                 if (d.is_directory())
                 {
                     std::string k = d.path().filename();
-                    auto wms = _container.emplace(std::make_pair(k, id().withProviderSegmentName(k)));
+                    auto wms = _container.emplace(k, id().withProviderSegmentName(k));
                     wms.first->second.reload(p_ptr);
                 }
 
@@ -87,7 +87,7 @@ namespace armarx::armem::d_ltm
             else
             {
                 std::filesystem::create_directory(_fullPath() / k);
-                auto wms = _container.emplace(std::make_pair(k, id().withProviderSegmentName(k)));
+                auto wms = _container.emplace(k, id().withProviderSegmentName(k));
                 wms.first->second.path = path;
                 wms.first->second.append(s);
             }
diff --git a/source/RobotAPI/libraries/armem/core/diskmemory/Memory.cpp b/source/RobotAPI/libraries/armem/core/diskmemory/Memory.cpp
index 874d189d6a22a79c9e015d800c292f9af075cfea..1038f5bfbed5d2f19b06819471e65cb5d0aab042 100644
--- a/source/RobotAPI/libraries/armem/core/diskmemory/Memory.cpp
+++ b/source/RobotAPI/libraries/armem/core/diskmemory/Memory.cpp
@@ -55,7 +55,7 @@ namespace armarx::armem::d_ltm
                 if (d.is_directory())
                 {
                     std::string k = d.path().filename();
-                    auto wms = _container.emplace(std::make_pair(k, id().withCoreSegmentName(k)));
+                    auto wms = _container.emplace(k, id().withCoreSegmentName(k));
                     wms.first->second.reload(path);
                 }
             }
@@ -75,7 +75,7 @@ namespace armarx::armem::d_ltm
             {
                 std::filesystem::create_directory(_fullPath() / k);
 
-                auto wms = _container.emplace(std::make_pair(k, id().withCoreSegmentName(k)));
+                auto wms = _container.emplace(k, id().withCoreSegmentName(k));
                 wms.first->second.path = path;
                 wms.first->second.append(s);
             }
diff --git a/source/RobotAPI/libraries/armem/core/diskmemory/ProviderSegment.cpp b/source/RobotAPI/libraries/armem/core/diskmemory/ProviderSegment.cpp
index 77d38171c15a0c5b6022c28c8d7ad5ece1a5b62a..1132b2fca64d906276c60886e5d50486b7126c8b 100644
--- a/source/RobotAPI/libraries/armem/core/diskmemory/ProviderSegment.cpp
+++ b/source/RobotAPI/libraries/armem/core/diskmemory/ProviderSegment.cpp
@@ -64,7 +64,7 @@ namespace armarx::armem::d_ltm
                 if (d.is_directory())
                 {
                     std::string k = d.path().filename();
-                    auto wms = _container.emplace(std::make_pair(k, id().withEntityName(k)));
+                    auto wms = _container.emplace(k, id().withEntityName(k));
                     wms.first->second.reload(p_ptr);
                 }
 
@@ -116,7 +116,7 @@ namespace armarx::armem::d_ltm
                     return;
                 }
 
-                auto wms = _container.emplace(std::make_pair(k, id().withEntityName(k)));
+                auto wms = _container.emplace(k, id().withEntityName(k));
                 wms.first->second.path = path;
                 wms.first->second.append(s);
             }
diff --git a/source/RobotAPI/libraries/armem/core/longtermmemory/CoreSegment.cpp b/source/RobotAPI/libraries/armem/core/longtermmemory/CoreSegment.cpp
index 7c4307da5395a58a6bdfce57c18705cefe535f7f..a64a5982e143e2627718f5039d3559b2d3479348 100644
--- a/source/RobotAPI/libraries/armem/core/longtermmemory/CoreSegment.cpp
+++ b/source/RobotAPI/libraries/armem/core/longtermmemory/CoreSegment.cpp
@@ -51,7 +51,7 @@ namespace armarx::armem::ltm
             }
             else
             {
-                auto wms = _container.emplace(std::make_pair(k, id().withProviderSegmentName(k)));
+                auto wms = _container.emplace(k, id().withProviderSegmentName(k));
                 wms.first->second.dbsettings = dbsettings;
                 wms.first->second.reload();
             }
@@ -78,7 +78,7 @@ namespace armarx::armem::ltm
                                                        << bsoncxx::builder::stream::finalize;
                 coll.insert_one(foreign_key.view());
 
-                auto wms = _container.emplace(std::make_pair(k, id().withProviderSegmentName(k)));
+                auto wms = _container.emplace(k, id().withProviderSegmentName(k));
                 wms.first->second.dbsettings = dbsettings;
                 wms.first->second.append(s);
             }
diff --git a/source/RobotAPI/libraries/armem/core/longtermmemory/Memory.cpp b/source/RobotAPI/libraries/armem/core/longtermmemory/Memory.cpp
index 7edf8946abe9bbf5967454a99ad73fefee535686..fbea444e9d44008407703fe7b7f8b007179726b6 100644
--- a/source/RobotAPI/libraries/armem/core/longtermmemory/Memory.cpp
+++ b/source/RobotAPI/libraries/armem/core/longtermmemory/Memory.cpp
@@ -82,7 +82,7 @@ namespace armarx::armem::ltm
             }
             else
             {
-                auto wms = _container.emplace(std::make_pair(k, id().withCoreSegmentName(k)));
+                auto wms = _container.emplace(k, id().withCoreSegmentName(k));
                 wms.first->second.dbsettings = dbsettings;
                 wms.first->second.reload();
             }
@@ -119,7 +119,7 @@ namespace armarx::armem::ltm
                                                        << bsoncxx::builder::stream::finalize;
                 coll.insert_one(foreign_key.view());
 
-                auto wms = _container.emplace(std::make_pair(k, id().withCoreSegmentName(k)));
+                auto wms = _container.emplace(k, id().withCoreSegmentName(k));
                 wms.first->second.dbsettings = dbsettings;
                 wms.first->second.append(s);
             }
diff --git a/source/RobotAPI/libraries/armem/core/longtermmemory/ProviderSegment.cpp b/source/RobotAPI/libraries/armem/core/longtermmemory/ProviderSegment.cpp
index 7bf439bfec2282d6919d69af1f94d9d7384cc4f8..aac80459904cae59550ecdf33f7057f92ed03aa4 100644
--- a/source/RobotAPI/libraries/armem/core/longtermmemory/ProviderSegment.cpp
+++ b/source/RobotAPI/libraries/armem/core/longtermmemory/ProviderSegment.cpp
@@ -50,7 +50,7 @@ namespace armarx::armem::ltm
             }
             else
             {
-                auto wms = _container.emplace(std::make_pair(k, id().withEntityName(k)));
+                auto wms = _container.emplace(k, id().withEntityName(k));
                 wms.first->second.dbsettings = dbsettings;
                 wms.first->second.reload();
             }
@@ -77,7 +77,7 @@ namespace armarx::armem::ltm
                                                        << bsoncxx::builder::stream::finalize;
                 coll.insert_one(foreign_key.view());
 
-                auto wms = _container.emplace(std::make_pair(k, id().withEntityName(k)));
+                auto wms = _container.emplace(k, id().withEntityName(k));
                 wms.first->second.dbsettings = dbsettings;
                 wms.first->second.append(s);
             }