Index: /code/trunk/data/levels/includes/pickups.oxi
===================================================================
--- /code/trunk/data/levels/includes/pickups.oxi	(revision 6724)
+++ /code/trunk/data/levels/includes/pickups.oxi	(revision 6725)
Index: /code/trunk/src/modules/pickup/PickupManager.cc
===================================================================
--- /code/trunk/src/modules/pickup/PickupManager.cc	(revision 6724)
+++ /code/trunk/src/modules/pickup/PickupManager.cc	(revision 6725)
@@ -51,5 +51,5 @@
     DeclareToluaInterface(Pickup);
     
-    ManageScopedSingleton(PickupManager, ScopeID::Root, false);
+    ManageScopedSingleton(PickupManager, ScopeID::Graphics, false);
     
     /*static*/ const std::string PickupManager::guiName_s = "PickupInventory";
@@ -64,4 +64,6 @@
         
         this->defaultRepresentation_ = new PickupRepresentation();
+        
+        COUT(3) << "PickupManager created." << std::endl;
     }
     
@@ -75,4 +77,8 @@
         if(this->defaultRepresentation_ != NULL)
             this->defaultRepresentation_->destroy();
+        
+        this->representations_.clear();
+        
+        COUT(3) << "PickupManager destroyed." << std::endl;
     }
     
@@ -89,6 +95,6 @@
     */
     bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
-    {
-        if(this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a RepresentationRegistered.
+    {       
+        if(identifier == NULL || representation == NULL || this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a Representation registered.
             return false;
         
@@ -96,4 +102,29 @@
         
         COUT(4) << "PickupRepresentation " << representation << " registered with the PickupManager." << std::endl;
+        return true;
+    }
+    
+    /**
+    @brief
+        Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
+    @param identifier
+        The PickupIdentifier identifying the Pickupable.
+    @param representation
+        A pointer to the PickupRepresentation.
+    @return
+        Returns true if successful and false if not.
+    */
+    bool PickupManager::unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
+    {       
+        if(identifier == NULL || representation == NULL)
+            return false;
+        
+        std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
+        if(it == this->representations_.end()) //!< If the Pickupable is not registered in the first place.
+            return false;
+        
+        this->representations_.erase(it);
+        
+        COUT(4) << "PickupRepresentation " << representation << " unregistered with the PickupManager." << std::endl;
         return true;
     }
Index: /code/trunk/src/modules/pickup/PickupManager.h
===================================================================
--- /code/trunk/src/modules/pickup/PickupManager.h	(revision 6724)
+++ /code/trunk/src/modules/pickup/PickupManager.h	(revision 6725)
@@ -67,4 +67,5 @@
             
             bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
+            bool unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
             PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
             
Index: /code/trunk/src/modules/pickup/PickupRepresentation.cc
===================================================================
--- /code/trunk/src/modules/pickup/PickupRepresentation.cc	(revision 6724)
+++ /code/trunk/src/modules/pickup/PickupRepresentation.cc	(revision 6725)
@@ -49,5 +49,5 @@
         This is primarily for use of the PickupManager in creating a default PickupRepresentation.
     */
-    PickupRepresentation::PickupRepresentation() : BaseObject(NULL), spawnerRepresentation_(NULL)
+    PickupRepresentation::PickupRepresentation() : BaseObject(NULL), spawnerRepresentation_(NULL), pickup_(NULL)
     {
         RegisterObject(PickupRepresentation);
@@ -60,5 +60,5 @@
         Default Constructor. Registers the object and initializes its member variables.
     */
-    PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), spawnerRepresentation_(NULL)
+    PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), spawnerRepresentation_(NULL), pickup_(NULL)
     {
         RegisterObject(PickupRepresentation);
@@ -75,4 +75,7 @@
         if(this->spawnerRepresentation_ != NULL)
             this->spawnerRepresentation_->destroy();
+        
+        if(this->pickup_ != NULL)
+            PickupManager::getInstance().unregisterRepresentation(this->pickup_->getPickupIdentifier(), this);
     }
     
@@ -87,5 +90,4 @@
         this->spawnerTemplate_ = "";
         this->inventoryRepresentation_ = "Default";
-        this->pickup_ = NULL;
     }
     
Index: /code/trunk/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- /code/trunk/src/orxonox/interfaces/Pickupable.cc	(revision 6724)
+++ /code/trunk/src/orxonox/interfaces/Pickupable.cc	(revision 6725)
@@ -46,5 +46,5 @@
         Constructor. Registers the objects and initializes its member variables.
     */
-    Pickupable::Pickupable() : used_(false), pickedUp_(false)
+    Pickupable::Pickupable() : pickupIdentifier_(NULL), used_(false), pickedUp_(false)
     {        
         RegisterRootObject(Pickupable);
@@ -69,4 +69,7 @@
             this->setCarrier(NULL);
         }
+        
+        if(this->pickupIdentifier_ != NULL)
+            this->pickupIdentifier_->destroy();
     }
     
Index: /code/trunk/src/orxonox/pickup/PickupIdentifier.cc
===================================================================
--- /code/trunk/src/orxonox/pickup/PickupIdentifier.cc	(revision 6724)
+++ /code/trunk/src/orxonox/pickup/PickupIdentifier.cc	(revision 6725)
@@ -48,4 +48,7 @@
         RegisterRootObject(PickupIdentifier);
         
+        if(pickup == NULL)
+            COUT(1) << "Error, PickupIdentifier was created without a valid Pickupable." << std::endl;
+        
         this->pickup_ = pickup;
     }
@@ -53,5 +56,5 @@
     PickupIdentifier::~PickupIdentifier()
     {
-        
+
     }
     
@@ -66,4 +69,28 @@
     int PickupIdentifier::compare(const PickupIdentifier* identifier) const
     {
+        if(identifier == NULL)
+        {
+            return 1;
+            COUT(1) << "Error in PickupIdentifier::compare: Input Identifier is NULL." << std::endl;
+        }
+        
+        if(identifier->pickup_ == NULL && this->pickup_ == NULL)
+        {
+            return 0;
+            COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl;
+        }
+        
+        if(identifier->pickup_ == NULL)
+        {
+            return 1;
+            COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl;
+        }
+        
+        if(this->pickup_ == NULL)
+        {
+            return -1;
+            COUT(1) << "Error in PickupIdentifier::compare: Pickup stored by Identifier is NULL." << std::endl;
+        }
+        
         //! If the classIdentifiers are not the same (meaning the PickupIdentifiers identify different classes), the obviously the two Pickupables identified by the PickupIdentifiers cannot be the same. An ordering is established through the alphabetical ordering of the respective classnames.
         if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier()))
@@ -91,5 +118,5 @@
         }
             
-        return false;
+        return 0;
     }
     
