Index: code/trunk/src/libraries/network/synchronisable/Serialise.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Serialise.h	(revision 8858)
+++ code/trunk/src/libraries/network/synchronisable/Serialise.h	(revision 9667)
@@ -41,7 +41,4 @@
 #include "util/Serialise.h"
 #include "core/CorePrereqs.h"
-#include "core/CoreIncludes.h"
-#include "core/BaseObject.h" // remove this if circular dependencies in BaseObject/SmartPtr are fixed
-//#include "core/SmartPtr.h"
 
 namespace orxonox{
Index: code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	(revision 8858)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	(revision 9667)
@@ -45,11 +45,13 @@
   uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
 
+  RegisterAbstractClass(Synchronisable).inheritsFrom(Class(OrxonoxInterface));
+
   /**
   * Constructor:
   * Initializes all Variables and sets the right objectID_
   */
-  Synchronisable::Synchronisable(BaseObject* creator )
-  {
-    RegisterRootObject(Synchronisable);
+  Synchronisable::Synchronisable(Context* context)
+  {
+      RegisterObject(Synchronisable);
     static uint32_t idCounter=0;
     objectMode_=0x1; // by default do not send data to server
@@ -69,9 +71,6 @@
     this->setPriority( Priority::Normal );
 
-    // get creator id
-    if( creator )
-      this->creatorID_ = creator->getSceneID();
-    else
-      this->creatorID_ = OBJECTID_UNKNOWN;
+    // get context id
+    this->contextID_ = this->findContextID(context);
   }
 
@@ -83,5 +82,5 @@
   {
     // delete callback function objects
-    if(!Identifier::isCreatingHierarchy()){
+    if(!IdentifierManager::getInstance().isCreatingHierarchy()){
       // remove object from the static objectMap
       if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
@@ -100,4 +99,19 @@
   }
 
+  /**
+   * @brief Returns the id of the context.
+   * If the context is not Synchronisable, it moves on to its parent, recursively.
+   */
+  uint32_t Synchronisable::findContextID(Context* context)
+  {
+      if (context == NULL)
+          return OBJECTID_UNKNOWN;
+
+      Synchronisable* synchronisableContext = orxonox_cast<Synchronisable*>(context);
+      if (synchronisableContext != NULL)
+          return synchronisableContext->getObjectID();
+      else
+          return this->findContextID(context->getParentContext());
+  }
 
   /**
@@ -142,9 +156,9 @@
     }
     assert(id);
-    BaseObject* creator = 0;
-    if (header.getCreatorID() != OBJECTID_UNKNOWN)
-    {
-      Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header.getCreatorID());
-      if (!synchronisable_creator)
+    Context* context = 0;
+    if (header.getContextID() != OBJECTID_UNKNOWN)
+    {
+      Synchronisable* synchronisable_context = Synchronisable::getSynchronisable(header.getContextID());
+      if (!synchronisable_context)
       {
         mem += header.getDataSize()+SynchronisableHeader::getSize(); //.TODO: this suckz.... remove size from header
@@ -153,8 +167,11 @@
       }
       else
-        creator = orxonox_cast<BaseObject*>(synchronisable_creator);
-    }
+        context = orxonox_cast<Context*>(synchronisable_context);
+    }
+    else
+      context = Context::getRootContext();
+
     assert(getSynchronisable(header.getObjectID())==0);   //make sure no object with this id exists
-    BaseObject *bo = id->fabricate(creator);
+    BaseObject *bo = orxonox_cast<BaseObject*>(id->fabricate(context));
     assert(bo);
     Synchronisable *no = orxonox_cast<Synchronisable*>(bo);
@@ -162,9 +179,13 @@
     assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
     no->setObjectID(header.getObjectID());
-    //no->creatorID=header.getCreatorID(); //TODO: remove this
+    //no->contextID=header.getContextID(); //TODO: remove this
     no->setClassID(header.getClassID());
-    assert(no->creatorID_ == header.getCreatorID());
-    if( creator )
-      bo->setLevel(creator->getLevel());          // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)
+    assert(no->contextID_ == header.getContextID());
+    if( context )
+    {
+      BaseObject* boContext = orxonox_cast<BaseObject*>(context);
+      if (boContext)
+          bo->setLevel(boContext->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)
+    }
     //assert(no->classID_ == header.getClassID());
     orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl;
@@ -274,5 +295,5 @@
 
     header.setObjectID( this->objectID_ );
-    header.setCreatorID( this->creatorID_ );
+    header.setContextID( this->contextID_ );
     header.setClassID( this->classID_ );
     header.setDataSize( tempsize );
@@ -331,5 +352,5 @@
       SynchronisableHeader syncHeader2(mem);
       assert( this->getClassID() == syncHeader2.getClassID() );
-      assert( this->getCreatorID() == syncHeader2.getCreatorID() );
+      assert( this->getContextID() == syncHeader2.getContextID() );
       mem += SynchronisableHeader::getSize();
       std::vector<SynchronisableVariableBase *>::iterator i;
Index: code/trunk/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.h	(revision 8858)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.h	(revision 9667)
@@ -40,5 +40,6 @@
 
 #include "util/mbool.h"
-#include "core/OrxonoxClass.h"
+#include "util/Output.h"
+#include "core/class/OrxonoxInterface.h"
 #include "SynchronisableVariable.h"
 #include "NetworkCallback.h"
@@ -106,5 +107,5 @@
    * @brief: stores information about a Synchronisable
    *
-   * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
+   * This class stores the information about a Synchronisable (objectID_, classID_, contextID_, dataSize)
    * in an emulated bitset.
    * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
@@ -112,5 +113,5 @@
    * Byte 5 to 8: objectID_
    * Byte 9 to 12: classID_
-   * Byte 13 to 16: creatorID_
+   * Byte 13 to 16: contextID_
    */
   class _NetworkExport SynchronisableHeader: public SynchronisableHeaderLight
@@ -125,8 +126,8 @@
       inline void setClassID(uint32_t classID_)
         { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()) = classID_; }
-      inline uint32_t getCreatorID() const
+      inline uint32_t getContextID() const
         { return *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4); }
-      inline void setCreatorID(uint32_t creatorID_)
-        { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4) = creatorID_; }
+      inline void setContextID(uint32_t contextID_)
+        { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4) = contextID_; }
       inline void operator=(SynchronisableHeader& h)
         { memcpy(data_, h.data_, getSize()); }
@@ -143,5 +144,5 @@
   * @author Oliver Scheuss
   */
-  class _NetworkExport Synchronisable : virtual public OrxonoxClass{
+  class _NetworkExport Synchronisable : virtual public OrxonoxInterface {
   public:
     friend class packet::Gamestate;
@@ -157,5 +158,5 @@
 
     inline uint32_t getObjectID() const {return this->objectID_;}
-    inline unsigned int getCreatorID() const {return this->creatorID_;}
+    inline unsigned int getContextID() const {return this->contextID_;}
     inline uint32_t getClassID() const {return this->classID_;}
     inline unsigned int getPriority() const { return this->objectFrequency_;}
@@ -169,5 +170,5 @@
 
   protected:
-    Synchronisable(BaseObject* creator);
+    Synchronisable(Context* context);
     template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
     template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
@@ -175,5 +176,5 @@
 
     void setPriority(unsigned int freq){ objectFrequency_ = freq; }
-
+    uint32_t findContextID(Context* context);
 
   private:
@@ -188,5 +189,5 @@
 
     uint32_t objectID_;
-    uint32_t creatorID_;
+    uint32_t contextID_;
     uint32_t classID_;
 
