Index: /code/branches/core5/src/libraries/core/BaseObject.h
===================================================================
--- /code/branches/core5/src/libraries/core/BaseObject.h	(revision 5804)
+++ /code/branches/core5/src/libraries/core/BaseObject.h	(revision 5805)
@@ -53,4 +53,5 @@
 #include "OrxonoxClass.h"
 #include "Super.h"
+#include "SmartPtr.h"
 
 namespace orxonox
@@ -134,6 +135,6 @@
             inline BaseObject* getCreator() const { return this->creator_; }
 
-            inline void setScene(Scene* scene) { this->scene_ = scene; }
-            inline Scene* getScene() const { return this->scene_; }
+            inline void setScene(const SmartPtr<Scene>& scene) { this->scene_ = scene; }
+            inline const SmartPtr<Scene>& getScene() const { return this->scene_; }
 
             inline void setGametype(Gametype* gametype)
@@ -194,5 +195,5 @@
             Namespace*             namespace_;
             BaseObject*            creator_;
-            Scene*                 scene_;
+            SmartPtr<Scene>        scene_;
             Gametype*              gametype_;
             Gametype*              oldGametype_;
Index: /code/branches/core5/src/libraries/core/OrxonoxClass.cc
===================================================================
--- /code/branches/core5/src/libraries/core/OrxonoxClass.cc	(revision 5804)
+++ /code/branches/core5/src/libraries/core/OrxonoxClass.cc	(revision 5805)
@@ -55,5 +55,5 @@
 //            COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ")" << std::endl;
 
-        assert(this->referenceCount_ == 0);
+        assert(this->referenceCount_ <= 0);
 
         delete this->metaList_;
Index: /code/branches/core5/src/libraries/core/OrxonoxClass.h
===================================================================
--- /code/branches/core5/src/libraries/core/OrxonoxClass.h	(revision 5804)
+++ /code/branches/core5/src/libraries/core/OrxonoxClass.h	(revision 5805)
@@ -135,5 +135,5 @@
             std::set<const Identifier*>* parents_;     //!< List of all parents of the object
             MetaObjectList* metaList_;                 //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
-            unsigned int referenceCount_;              //!< Counts the references from smart pointers to this object
+            int referenceCount_;                       //!< Counts the references from smart pointers to this object
             bool requestedDestruction_;                //!< Becomes true after someone called delete on this object
 
Index: /code/branches/core5/src/libraries/core/SmartPtr.h
===================================================================
--- /code/branches/core5/src/libraries/core/SmartPtr.h	(revision 5804)
+++ /code/branches/core5/src/libraries/core/SmartPtr.h	(revision 5805)
@@ -42,31 +42,41 @@
     {
         public:
-            inline SmartPtr() : pointer_(0)
-            {
-            }
-
-            inline SmartPtr(T* pointer) : pointer_(pointer)
-            {
-                if (this->pointer_)
-                    this->pointer_->incrementReferenceCount();
-            }
-
-            inline SmartPtr(const SmartPtr& other) : pointer_(other.pointer_)
-            {
-                if (this->pointer_)
-                    this->pointer_->incrementReferenceCount();
+            inline SmartPtr() : pointer_(0), base_(0)
+            {
+            }
+
+            inline SmartPtr(int) : pointer_(0), base_(0)
+            {
+            }
+
+            inline SmartPtr(T* pointer, bool bAddRef = true) : pointer_(pointer), base_(pointer)
+            {
+                if (this->base_ && bAddRef)
+                    this->base_->incrementReferenceCount();
+            }
+
+            inline SmartPtr(const SmartPtr& other) : pointer_(other.pointer_), base_(other.base_)
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
             }
 
             template <class O>
-            inline SmartPtr(const SmartPtr<O>& other) : pointer_(other.get())
-            {
-                if (this->pointer_)
-                    this->pointer_->incrementReferenceCount();
+            inline SmartPtr(const SmartPtr<O>& other) : pointer_(other.get()), base_(other.base_)
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
             }
 
             inline ~SmartPtr()
             {
-                if (this->pointer_)
-                    this->pointer_->decrementReferenceCount();
+                if (this->base_)
+                    this->base_->decrementReferenceCount();
+            }
+            
+            inline const SmartPtr& operator=(int)
+            {
+                SmartPtr(0).swap(*this);
+                return *this;
             }
 
@@ -96,5 +106,5 @@
 
             inline operator T*() const
-            {std::cout << "(implizit)";
+            {
                 return this->pointer_;
             }
@@ -117,7 +127,14 @@
             inline void swap(SmartPtr& other)
             {
-                T* temp = this->pointer_;
-                this->pointer_ = other.pointer_;
-                other.pointer_ = temp;
+                {
+                    T* temp = this->pointer_;
+                    this->pointer_ = other.pointer_;
+                    other.pointer_ = temp;
+                }
+                {
+                    OrxonoxClass* temp = this->base_;
+                    this->base_ = other.base_;
+                    other.base_ = temp;
+                }
             }
 
@@ -129,4 +146,5 @@
         private:
             T* pointer_;
+            OrxonoxClass* base_;
     };
 
Index: /code/branches/core5/src/modules/gamestates/GSLevel.cc
===================================================================
--- /code/branches/core5/src/modules/gamestates/GSLevel.cc	(revision 5804)
+++ /code/branches/core5/src/modules/gamestates/GSLevel.cc	(revision 5805)
@@ -242,9 +242,5 @@
     void GSLevel::unloadLevel()
     {
-        //////////////////////////////////////////////////////////////////////////////////////////
-        // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO //
-        //////////////////////////////////////////////////////////////////////////////////////////
-        // Loader::unload(startFile_); // TODO: REACTIVATE THIS IF LOADER::UNLOAD WORKS PROPERLY /
-        //////////////////////////////////////////////////////////////////////////////////////////
+        Loader::unload(startFile_s);
 
         delete startFile_s;
Index: /code/branches/core5/src/orxonox/CameraManager.cc
===================================================================
--- /code/branches/core5/src/orxonox/CameraManager.cc	(revision 5804)
+++ /code/branches/core5/src/orxonox/CameraManager.cc	(revision 5805)
@@ -53,5 +53,6 @@
     {
         if (this->fallbackCamera_)
-            this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
+            this->fallbackCameraScene_->getSceneManager()->destroyCamera(this->fallbackCamera_);
+        GUIManager::getInstance().setCamera(0);
     }
 
@@ -74,5 +75,5 @@
         else if (this->fallbackCamera_)
         {
-            this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
+            this->fallbackCameraScene_->getSceneManager()->destroyCamera(this->fallbackCamera_);
             this->fallbackCamera_ = 0;
         }
@@ -107,5 +108,8 @@
                 // there are no more cameras, create a fallback
                 if (!this->fallbackCamera_)
-                    this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
+                {
+                    this->fallbackCameraScene_ = camera->getScene();
+                    this->fallbackCamera_ = this->fallbackCameraScene_->getSceneManager()->createCamera(getUniqueNumberString());
+                }
                 this->useCamera(this->fallbackCamera_);
             }
Index: /code/branches/core5/src/orxonox/CameraManager.h
===================================================================
--- /code/branches/core5/src/orxonox/CameraManager.h	(revision 5804)
+++ /code/branches/core5/src/orxonox/CameraManager.h	(revision 5805)
@@ -42,4 +42,5 @@
 #include "util/OgreForwardRefs.h"
 #include "util/Singleton.h"
+#include "core/SmartPtr.h"
 
 namespace orxonox
@@ -67,4 +68,5 @@
             Ogre::Viewport*       viewport_;
             Ogre::Camera*         fallbackCamera_;
+            SmartPtr<Scene>       fallbackCameraScene_;
 
             static CameraManager* singletonPtr_s;
Index: /code/branches/core5/src/orxonox/Scene.cc
===================================================================
--- /code/branches/core5/src/orxonox/Scene.cc	(revision 5804)
+++ /code/branches/core5/src/orxonox/Scene.cc	(revision 5805)
@@ -54,5 +54,5 @@
         RegisterObject(Scene);
 
-        this->setScene(this);
+        this->setScene(SmartPtr<Scene>(this, false));
         this->bShadows_ = true;
 
