Index: System/FieldContainer/Misc/OSGFieldContainerUtils.cpp
===================================================================
--- System/FieldContainer/Misc/OSGFieldContainerUtils.cpp	(revision 2884)
+++ System/FieldContainer/Misc/OSGFieldContainerUtils.cpp	(working copy)
@@ -296,11 +296,16 @@
 
 void MemoryConsumption::scan(void)
 {
-    UInt32 numCont = FieldContainerFactory::the()->getNumContainers();
+    OSG::FieldContainerFactoryBase::ContainerStoreConstIt store_it(
+        OSG::FieldContainerFactory::the()->beginStore()
+    );
+    OSG::FieldContainerFactoryBase::ContainerStoreConstIt end(
+        OSG::FieldContainerFactory::the()->endStore()
+    );
 
-    for(UInt32 i = 0; i < numCont; ++i)
+    for(; end != store_it; ++store_it)
     {
-        FieldContainer *pFC = FieldContainerFactory::the()->getContainer(i);
+        FieldContainer *pFC((*store_it).second->getPtr());
 
         if(pFC == NULL)
             continue;
Index: Base/FieldContainer/Base/OSGFieldContainerFactory.inl
===================================================================
--- Base/FieldContainer/Base/OSGFieldContainerFactory.inl	(revision 2884)
+++ Base/FieldContainer/Base/OSGFieldContainerFactory.inl	(working copy)
@@ -54,7 +54,9 @@
     _pStoreLock->acquire();
 #endif
 
-    returnValue = _vContainerStore.size();
+    // We should still be able to get the size.
+    returnValue = _containerStore.size();
+    //returnValue = _nextContainerId;
 
 #ifndef OSG_EMBEDDED
     _pStoreLock->release();
@@ -73,14 +75,16 @@
     _pStoreLock->acquire();
 #endif
 
-    if(uiContainerId < _vContainerStore.size())
+    ContainerStoreConstIt sI = _containerStore.find(uiContainerId);
+
+    if(sI != _containerStore.end())
     {
-        if(_vContainerStore[uiContainerId] != NULL)
+        if (NULL != (*sI).second)
         {
 #ifdef OSG_MT_CPTR_ASPECT
-            returnValue = _vContainerStore[uiContainerId]->getPtr();
+            returnValue = (*sI).second->getPtr();
 #else
-            returnValue = _vContainerStore[uiContainerId];
+            returnValue = (*sI).second;
 #endif
         }
     }
@@ -102,9 +106,11 @@
     _pStoreLock->acquire();
 #endif
 
-    if(uiContainerId < _vContainerStore.size())
+    ContainerStoreConstIt sI = _containerStore.find(uiContainerId);
+
+    if(sI != _containerStore.end())
     {
-        returnValue = _vContainerStore[uiContainerId];
+        returnValue = (*sI).second;
     }
 
 #ifndef OSG_EMBEDDED
@@ -135,37 +141,5 @@
     }
 }
 
-
-inline
-bool FieldContainerFactoryBase::deregisterContainer(const UInt32 uiContainerId)
-{
-    bool returnValue = false;
-
-#ifndef OSG_EMBEDDED
-    _pStoreLock->acquire();
-#endif
-
-    if(uiContainerId < _vContainerStore.size())
-    {
-        _vContainerStore[uiContainerId] = NULL;
-    }
-#ifdef OSG_DEBUG
-    else
-    {
-        FWARNING(("FieldContainerFactory::unregisterFieldContainer:"
-                  "id %d inconsistent with store size %"PRISize"!\n",
-                uiContainerId,
-                _vContainerStore.size()));
-        returnValue = true;
-    }
-#endif
-
-#ifndef OSG_EMBEDDED
-    _pStoreLock->release();
-#endif
-
-    return returnValue;
-}
-
 OSG_END_NAMESPACE
 
Index: Base/FieldContainer/Base/OSGChangeList.cpp
===================================================================
--- Base/FieldContainer/Base/OSGChangeList.cpp	(revision 2884)
+++ Base/FieldContainer/Base/OSGChangeList.cpp	(working copy)
@@ -774,6 +774,7 @@
 {
     this->clear();
 
+    // TODO: Update to iterate over field containers in the map.
     UInt32 uiNumContainers = 
         FieldContainerFactory::the()->getNumContainers();
 
Index: Base/FieldContainer/Base/OSGFieldContainerFactory.h
===================================================================
--- Base/FieldContainer/Base/OSGFieldContainerFactory.h	(revision 2884)
+++ Base/FieldContainer/Base/OSGFieldContainerFactory.h	(working copy)
@@ -43,6 +43,7 @@
 #endif
 
 #include "OSGBaseTypes.h"
+#include "OSGDeprecatedCPP.h"
 #include "OSGSingletonHolder.h"
 #include "OSGContainerForwards.h"
 #include "OSGTypeBase.h"
@@ -50,7 +51,6 @@
 #include "OSGAspectStore.h"
 #include "OSGContainerIdMapper.h"
 
-//#include "OSGFieldContainer.h"
 
 #include <deque>
 
@@ -130,8 +130,9 @@
     typedef FieldContainer                *ContainerHandlerP;
 #endif
 
-    typedef std::deque<ContainerHandlerP>  ContainerStore;
-    typedef ContainerStore::iterator       ContainerStoreIt;
+    typedef OSG_HASH_MAP(UInt32, ContainerHandlerP)  ContainerStore;
+    typedef ContainerStore::iterator                 ContainerStoreIt;
+    typedef ContainerStore::const_iterator           ContainerStoreConstIt;
 
     /*---------------------------------------------------------------------*/
     /*! \name                      dcast                                   */
@@ -171,7 +172,10 @@
     ContainerPtr      getMappedContainer (UInt32 uiContainerId) const;
 
     Int32             findContainer      (ContainerPtr ptr    ) const;
-    
+
+    ContainerStoreConstIt beginStore(void) const;
+    ContainerStoreConstIt endStore  (void) const;
+
     /*! \}                                                                 */
     /*---------------------------------------------------------------------*/
     /*! \name                      Get                                     */
@@ -248,7 +252,8 @@
     LockRefPtr         _pStoreLock;
 #endif
 
-    ContainerStore     _vContainerStore;
+    UInt32             _nextContainerId;
+    ContainerStore     _containerStore;
 
     /*! Currently active field container mapper. */
     ContainerIdMapper *_pMapper;
Index: Base/FieldContainer/Base/OSGFieldContainerFactory.cpp
===================================================================
--- Base/FieldContainer/Base/OSGFieldContainerFactory.cpp	(revision 2884)
+++ Base/FieldContainer/Base/OSGFieldContainerFactory.cpp	(working copy)
@@ -80,10 +80,12 @@
 #ifndef OSG_EMBEDDED
     _pStoreLock     (NULL                   ),
 #endif
-    _vContainerStore(                       ),
+    _nextContainerId(0                      ),
+    _containerStore (                       ),
     _pMapper        (NULL                   )
 {
-    _vContainerStore.push_back(NULL);
+    _containerStore.insert(
+        ContainerStore::value_type(_nextContainerId++, NULL));
 }
 
 FieldContainerFactoryBase::FieldContainerFactoryBase(
@@ -93,10 +95,12 @@
 #ifndef OSG_EMBEDDED
     _pStoreLock     (NULL         ),
 #endif
-	_vContainerStore(             ),
+    _nextContainerId(0            ),
+    _containerStore (             ),
     _pMapper        (NULL         )
 {
-    _vContainerStore.push_back(NULL);
+    _containerStore.insert(
+        ContainerStore::value_type(_nextContainerId++, NULL));
 }
 
 /*-------------------------------------------------------------------------*/
@@ -115,8 +119,8 @@
         return true;
 
 #ifndef OSG_EMBEDDED
-    _pStoreLock = ThreadManager::the()->getLock("ContainerFactory::slock",
-                                                false);
+    _pStoreLock = ThreadManager::the()->getLock(
+        "ContainerFactory::_pStorelock", false);
 
     PINFO << "Got store lock " << _pStoreLock.get() << std::endl;
 
@@ -144,32 +148,33 @@
     this->_bInitialized = false;
 
 #ifdef OSG_DEBUG
-    ContainerStoreIt sI = _vContainerStore.begin();
-    ContainerStoreIt sE = _vContainerStore.end  ();
-    
-    for(UInt32 i = 0; sI != sE; ++sI, ++i)
+    ContainerStoreConstIt sI = _containerStore.begin();
+    ContainerStoreConstIt sE = _containerStore.end  ();
+
+    for(; sI != sE; ++sI)
     {
-        if((*sI) != NULL)
+        if((*sI).second != NULL)
         {
             FWARNING(("FieldContainerFactoryBase::terminate: "
-                      "Entry [%d] is not NULL ([%p]). \n", i, *sI));
+                      "Entry [%d] is not NULL ([%p]). \n",
+                      (*sI).first, (*sI).second));
                                               
-            for(UInt32 j = 0; j < (*sI)->getNumAspects(); ++j)
+            for(UInt32 j = 0; j < (*sI).second->getNumAspects(); ++j)
             {
-                if((*sI)->getPtr(j) != NULL)
+                if((*sI).second->getPtr(j) != NULL)
                 {
                     FWARNING(("  [%d] [%p] [%s] [%d %d]\n",
                               j, 
-                              (*sI)->getPtr(j), 
-                              (*sI)->getPtr(j)->getType().getCName(),
-                              (*sI)->getPtr(j)->getRefCount(),
-                              (*sI)->getPtr(j)->getWeakRefCount() ));
+                              (*sI).second->getPtr(j), 
+                              (*sI).second->getPtr(j)->getType().getCName(),
+                              (*sI).second->getPtr(j)->getRefCount(),
+                              (*sI).second->getPtr(j)->getWeakRefCount() ));
                 }
                 else
                 {
                     FWARNING(("  [%d] [%p] [] [N/A N/A]\n",
                               j, 
-                              (*sI)->getPtr(j)));
+                              (*sI).second->getPtr(j)));
                 }
             }
         }
@@ -185,6 +190,18 @@
     return Inherited::initializeFactoryPost();
 }
 
+FieldContainerFactoryBase::ContainerStoreConstIt
+FieldContainerFactoryBase::beginStore(void) const
+{
+    return _containerStore.begin();
+}
+
+FieldContainerFactoryBase::ContainerStoreConstIt
+FieldContainerFactoryBase::endStore(void) const
+{
+    return _containerStore.end();
+}
+
 UInt32 FieldContainerFactoryBase::registerContainer(
     const ContainerPtr &pContainer)
 {
@@ -192,32 +209,65 @@
     VALGRIND_CHECK_VALUE_IS_DEFINED(pContainer);
 #endif
 
-    UInt32 returnValue = 0;
-
 #ifndef OSG_EMBEDDED
     _pStoreLock->acquire();
 #endif
 
+    UInt32 returnValue = _nextContainerId++;
+
 #ifdef OSG_MT_CPTR_ASPECT
     ContainerHandlerP pHandler = NULL;
 
     if(pContainer != NULL)
         pHandler = pContainer->getAspectStore();
 
-    _vContainerStore.push_back(pHandler);
+    _containerStore.insert(
+        ContainerStore::value_type(returnValue, pHandler));
 #else
-    _vContainerStore.push_back(pContainer);
+    _containerStore.insert(
+        ContainerStore::value_type(returnValue, pContainer));
 #endif
 
-    returnValue = _vContainerStore.size() - 1;
+#ifndef OSG_EMBEDDED
+    _pStoreLock->release();
+#endif
 
+    return returnValue;
+}
+
+bool FieldContainerFactoryBase::deregisterContainer(const UInt32 uiContainerId)
+{
+    bool returnValue = false;
+
 #ifndef OSG_EMBEDDED
+    _pStoreLock->acquire();
+#endif
+
+    ContainerStoreConstIt sI(_containerStore.find(uiContainerId));
+    if (sI != _containerStore.end())
+    {
+        _containerStore.erase(sI);
+    }
+#ifdef OSG_DEBUG
+    else
+    {
+        SWARNING << "FieldContainerFactory::unregisterContainer: "
+                 << "id '" << uiContainerId << "' not found in "
+                 << "container store!"
+                 << std::endl;
+
+        returnValue = true;
+    }
+#endif
+
+#ifndef OSG_EMBEDDED
     _pStoreLock->release();
 #endif
 
     return returnValue;
 }
 
+
 /*! Try to find the ptr container in the factory. Primarily used to verify
 that a container is still valid and registered with the factory. As this
 function does not access the ptr itself at all, it is safe to call it with
@@ -236,20 +286,19 @@
     _pStoreLock->acquire();
 #endif
 
-    ContainerStore::const_iterator it, end;
-    Int32 id = 0;
-    Int32 returnValue = -1;
+    ContainerStoreConstIt sI          = _containerStore.begin();
+    ContainerStoreConstIt sE          = _containerStore.end  ();
+    Int32                 returnValue = -1;
     
-    for(it = _vContainerStore.begin(), end = _vContainerStore.end();
-        it != end; ++it, ++id)
+    for(; sI != sE; ++sI)
     {
 #ifdef OSG_MT_CPTR_ASPECT
-        if((*it)->getPtr() == ptr)
+        if((*sI).second->getPtr() == ptr)
 #else
-        if(*it == ptr)
+        if((*sI).second == ptr)
 #endif
         {
-            returnValue = id;
+            returnValue = (*sI).first;
             break;
         }
     }
@@ -270,32 +319,33 @@
     _pStoreLock->acquire();
 #endif
 
-    ContainerStoreIt sI = _vContainerStore.begin();
-    ContainerStoreIt sE = _vContainerStore.end  ();
+    ContainerStoreConstIt sI = _containerStore.begin();
+    ContainerStoreConstIt sE = _containerStore.end  ();
     
-    for(UInt32 i = 0; sI != sE; ++sI, ++i)
+    for(; sI != sE; ++sI)
     {
-        if((*sI) != NULL)
+        if((*sI).second != NULL)
         {
             FWARNING(("FieldContainerFactoryBase::dump: "
-                      "Entry [%d] is not NULL ([%p]). \n", i, *sI));
+                      "Entry [%d] is not NULL ([%p]). \n",
+                      (*sI).first, (*sI).second));
                                               
-            for(UInt32 j = 0; j < (*sI)->getNumAspects(); ++j)
+            for(UInt32 j = 0; j < (*sI).second->getNumAspects(); ++j)
             {
-                if((*sI)->getPtr(j) != NULL)
+                if((*sI).second->getPtr(j) != NULL)
                 {
                     FWARNING(("  [%d] [%p] [%s] [%d %d]\n",
                               j, 
-                              (*sI)->getPtr(j), 
-                              (*sI)->getPtr(j)->getType().getCName(),
-                              (*sI)->getPtr(j)->getRefCount(),
-                              (*sI)->getPtr(j)->getWeakRefCount() ));
+                              (*sI).second->getPtr(j), 
+                              (*sI).second->getPtr(j)->getType().getCName(),
+                              (*sI).second->getPtr(j)->getRefCount(),
+                              (*sI).second->getPtr(j)->getWeakRefCount() ));
                 }
                 else
                 {
                     FWARNING(("  [%d] [%p] [] [N/A N/A]\n",
                               j, 
-                              (*sI)->getPtr(j)));
+                              (*sI).second->getPtr(j)));
                 }
             }
         }
