Index: /code/branches/core7/src/libraries/core/singleton/Scope.h
===================================================================
--- /code/branches/core7/src/libraries/core/singleton/Scope.h	(revision 10462)
+++ /code/branches/core7/src/libraries/core/singleton/Scope.h	(revision 10463)
@@ -39,7 +39,4 @@
 Instances of orxonox::ScopeListener can register in orxonox::ScopeMAnager for a given @a scope and will get a
 notification if the corresponding orxonox::Scope object changes its state.
-
-To avoid multiple instances of orxonox::Scope<@a scope> in different libraries, each instance of orxonox::Scope
-registers in orxonox::ScopeManager, where they are linked statically in the core library.
 
 Scopes are usually used to control the creation and destruction of Singletons.
@@ -104,47 +101,27 @@
     {
         public:
-            //! Constructor: Increases the instance counter and activates the scope if the count went from 0 to 1. Counts >1 don't change anything.
+            //! Constructor: activate the listeners.
             Scope()
             {
                 orxout(internal_status) << "creating scope... (" << scope << ")" << endl;
 
-                try
+                Loki::ScopeGuard deactivator = Loki::MakeObjGuard(*this, &Scope::deactivateScope);
+                ScopeManager::getInstance().addScope(scope);
+                for (typename std::set<ScopeListener*>::iterator it = ScopeManager::getInstance().getListeners(scope).begin(); it != ScopeManager::getInstance().getListeners(scope).end(); )
                 {
-                    ScopeManager::getInstance().getInstanceCount(scope)++;
-                    assert(ScopeManager::getInstance().getInstanceCount(scope) > 0);
-                    if (ScopeManager::getInstance().getInstanceCount(scope) == 1)
-                    {
-                        Loki::ScopeGuard deactivator = Loki::MakeObjGuard(*this, &Scope::deactivateListeners);
-                        for (typename std::set<ScopeListener*>::iterator it = ScopeManager::getInstance().getListeners(scope).begin(); it != ScopeManager::getInstance().getListeners(scope).end(); )
-                        {
-                            (*it)->activated();
-                            (*(it++))->bActivated_ = true;
-                        }
-                        deactivator.Dismiss();
-                    }
+                    (*it)->activated();
+                    (*(it++))->bActivated_ = true;
                 }
-                catch (...)
-                {
-                    ScopeManager::getInstance().getInstanceCount(scope)--;
-                    throw;
-                }
+                deactivator.Dismiss();
 
                 orxout(internal_status) << "created scope (" << scope << ")" << endl;
             }
 
-            //! Destructor: Decreases the instance counter and deactivates the scope if the count went from 1 to 0. Counts >0 don't change anything.
+            //! Destructor: deactivate the listeners.
             ~Scope()
             {
                 orxout(internal_status) << "destroying scope... (" << scope << ")" << endl;
 
-                ScopeManager::getInstance().getInstanceCount(scope)--;
-
-                // This shouldn't happen but just to be sure: check if the count is positive
-                assert(ScopeManager::getInstance().getInstanceCount(scope) >= 0);
-                if (ScopeManager::getInstance().getInstanceCount(scope) < 0)
-                    ScopeManager::getInstance().getInstanceCount(scope) = 0;
-
-                if (ScopeManager::getInstance().getInstanceCount(scope) == 0)
-                    this->deactivateListeners();
+                this->deactivateScope();
 
                 orxout(internal_status) << "destroyed scope (" << scope << ")" << endl;
@@ -152,6 +129,7 @@
 
             //! Deactivates the listeners of this scope in case the scope is destroyed or the construction fails.
-            void deactivateListeners()
+            void deactivateScope()
             {
+                ScopeManager::getInstance().removeScope(scope);
                 for (typename std::set<ScopeListener*>::iterator it = ScopeManager::getInstance().getListeners(scope).begin(); it != ScopeManager::getInstance().getListeners(scope).end(); )
                 {
@@ -172,5 +150,5 @@
             static bool isActive()
             {
-                return (ScopeManager::getInstance().getInstanceCount(scope) > 0);
+                return ScopeManager::getInstance().isActive(scope);
             }
     };
Index: /code/branches/core7/src/libraries/core/singleton/ScopeManager.cc
===================================================================
--- /code/branches/core7/src/libraries/core/singleton/ScopeManager.cc	(revision 10462)
+++ /code/branches/core7/src/libraries/core/singleton/ScopeManager.cc	(revision 10463)
@@ -44,4 +44,19 @@
     }
 
+    void ScopeManager::addScope(ScopeID::Value scope)
+    {
+        this->activeScopes_.insert(scope);
+    }
+
+    void ScopeManager::removeScope(ScopeID::Value scope)
+    {
+        this->activeScopes_.erase(scope);
+    }
+
+    bool ScopeManager::isActive(ScopeID::Value scope)
+    {
+        return this->activeScopes_.find(scope) != this->activeScopes_.end();
+    }
+
     void ScopeManager::addListener(ScopeListener* listener)
     {
Index: /code/branches/core7/src/libraries/core/singleton/ScopeManager.h
===================================================================
--- /code/branches/core7/src/libraries/core/singleton/ScopeManager.h	(revision 10462)
+++ /code/branches/core7/src/libraries/core/singleton/ScopeManager.h	(revision 10463)
@@ -57,14 +57,16 @@
             static ScopeManager& getInstance();
 
+            void addScope(ScopeID::Value scope);
+            void removeScope(ScopeID::Value scope);
+            bool isActive(ScopeID::Value scope);
+
             void addListener(ScopeListener* listener);
             void removeListener(ScopeListener* listener);
 
-            inline int& getInstanceCount(ScopeID::Value scope)
-                { return this->instanceCounts_[scope]; }
             inline std::set<ScopeListener*>& getListeners(ScopeID::Value scope)
                 { return this->listeners_[scope]; }
 
         private:
-            std::map<ScopeID::Value, int> instanceCounts_;                  //!< Counts the number of active instances (>0 means active) for a scope
+            std::set<ScopeID::Value> activeScopes_;
             std::map<ScopeID::Value, std::set<ScopeListener*> > listeners_; //!< Stores all listeners for a scope
     };
