Index: /code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.cc
===================================================================
--- /code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.cc	(revision 10032)
+++ /code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.cc	(revision 10033)
@@ -138,10 +138,13 @@
         if (this->attachedShapes_.find(shape) != this->attachedShapes_.end())
         {
+            orxout() << "Still going..." << endl;
             this->attachedShapes_.erase(shape);
             if (shape->getCollisionShape())
                 this->compoundShape_->removeChildShape(shape->getCollisionShape()); // TODO: Apparently this is broken?
             shape->notifyDetached();
+            orxout() << "Still going...." << endl;
 
             this->updatePublicShape();
+            orxout() << "Still going....." << endl;
         }
         else
Index: /code/branches/modularships/src/orxonox/items/ShipPart.cc
===================================================================
--- /code/branches/modularships/src/orxonox/items/ShipPart.cc	(revision 10032)
+++ /code/branches/modularships/src/orxonox/items/ShipPart.cc	(revision 10033)
@@ -89,4 +89,5 @@
     {
         this->parent_->removeShipPart(this);
+        orxout() << this->getName() << " has died." << endl;
     }
 
Index: /code/branches/modularships/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- /code/branches/modularships/src/orxonox/worldentities/WorldEntity.cc	(revision 10032)
+++ /code/branches/modularships/src/orxonox/worldentities/WorldEntity.cc	(revision 10033)
@@ -580,4 +580,5 @@
     {
         // Note: The collision shapes may not be detached with this function!
+        orxout() << "WE: detachCS()" << endl;
         this->collisionShape_->detach(shape);
         // Note: this->collisionShape_ already notifies us of any changes.
Index: /code/branches/modularships/src/orxonox/worldentities/WorldEntity.h
===================================================================
--- /code/branches/modularships/src/orxonox/worldentities/WorldEntity.h	(revision 10032)
+++ /code/branches/modularships/src/orxonox/worldentities/WorldEntity.h	(revision 10033)
@@ -72,4 +72,5 @@
     {
         friend class Scene;
+        friend class ModularSpaceShip;
 
         public:
Index: /code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- /code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	(revision 10032)
+++ /code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	(revision 10033)
@@ -40,4 +40,5 @@
 #include "items/ShipPart.h"
 #include "worldentities/StaticEntity.h"
+#include "collisionshapes/WorldEntityCollisionShape.h"
 #include <BulletCollision/CollisionShapes/btCollisionShape.h>
 
@@ -78,5 +79,5 @@
     {
         // iterate through all attached objects
-        for (unsigned int i=0; i < this->getNumAttachedObj(); i++)
+        for (unsigned int i=0; i < (unsigned int)(this->getNumAttachedObj()); i++)
         {
             if (this->getAttachedObject(i) == NULL)
@@ -179,4 +180,6 @@
         //orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl;
 
+        orxout() << "CP before handleHit" << endl;
+
         if (this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL)
             this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator);
@@ -276,9 +279,11 @@
             if (itt->second == part)
             {
-                //this->detach(itt->first);
+                this->detach(itt->first);
                 //itt->first->destroy();
-                itt->first->setActive(false);
-                itt->first->setVisible(false);
-                itt->first->setCollisionResponse(false);
+                //itt->first->setActive(false);
+                //itt->first->setVisible(false);
+                //itt->first->setCollisionResponse(false);
+                //itt->first->setCollisionType(None);
+                //itt->first->deactivatePhysics();
                 this->partMap_.erase(itt);
             }
@@ -286,3 +291,36 @@
     }
 
+    /**
+    @brief
+        Detaches a child WorldEntity from this instance.
+    */
+    void ModularSpaceShip::detach(WorldEntity* object)
+    {
+        std::set<WorldEntity*>::iterator it = this->children_.find(object);
+        if (it == this->children_.end())
+        {
+            orxout(internal_warning) << "Cannot detach an object that is not a child." << endl;
+            return;
+        }
+
+        // collision shapes
+        orxout() << "MSS: detach()" << endl;
+
+        this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
+        this->detachCollisionShape(object->collisionShape_);  // after succeeding, causes a crash in the collision handling
+        this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
+
+        // mass
+        if (object->getMass() > 0.0f)
+        {
+            this->childrenMass_ -= object->getMass();
+            recalculateMassProps();
+        }
+
+        this->detachNode(object->node_);
+        this->children_.erase(it);        // this causes a crash when unloading the level. Or not?
+
+        object->notifyDetached();
+        orxout() << "MSS: detach() completed." << endl;
+    }
 }
Index: /code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h
===================================================================
--- /code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h	(revision 10032)
+++ /code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h	(revision 10033)
@@ -118,4 +118,6 @@
             void removeShipPart(ShipPart* part);
 
+            void detach(WorldEntity* object);
+
             virtual void updatePartAssignment();
 
