Index: /code/trunk/src/modules/overlays/hud/HUDHealthBar.cc
===================================================================
--- /code/trunk/src/modules/overlays/hud/HUDHealthBar.cc	(revision 6053)
+++ /code/trunk/src/modules/overlays/hud/HUDHealthBar.cc	(revision 6054)
@@ -48,5 +48,5 @@
         this->textoverlay_ = new OverlayText(this);
 
-        assert(this->textoverlay_);
+        assert(this->textoverlay_.get());
 
         this->textoverlay_->setCaption("");
@@ -56,5 +56,8 @@
     {
         if (this->isInitialized())
+        {
             this->textoverlay_->destroy();
+            this->textoverlay_ = 0;
+        }
     }
 
@@ -106,5 +109,5 @@
         SUPER(HUDHealthBar, changedOverlayGroup);
 
-        this->getOverlayGroup()->addElement(this->textoverlay_);
+        this->getOverlayGroup()->addElement(this->textoverlay_.get());
     }
 
Index: /code/trunk/src/modules/overlays/hud/HUDHealthBar.h
===================================================================
--- /code/trunk/src/modules/overlays/hud/HUDHealthBar.h	(revision 6053)
+++ /code/trunk/src/modules/overlays/hud/HUDHealthBar.h	(revision 6054)
@@ -112,5 +112,5 @@
         private:
             WeakPtr<Pawn> owner_;
-            OverlayText* textoverlay_;
+            SmartPtr<OverlayText> textoverlay_;
             bool bUseBarColour_;
             ColourValue textColour_;
Index: /code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc
===================================================================
--- /code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc	(revision 6053)
+++ /code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.cc	(revision 6054)
@@ -34,4 +34,5 @@
 #include "gametypes/UnderAttack.h"
 #include "worldentities/pawns/Destroyer.h"
+#include "overlays/OverlayGroup.h"
 
 namespace orxonox
@@ -58,5 +59,8 @@
     {
         if (this->isInitialized())
+        {
             this->text_->destroy();
+            this->text_ = 0;
+        }
     }
 
@@ -90,4 +94,11 @@
         }
     }
+    
+    void UnderAttackHealthBar::changedOverlayGroup()
+    {
+        SUPER(UnderAttackHealthBar, changedOverlayGroup);
+        
+        this->getOverlayGroup()->addElement(this->text_.get());
+    }
 
     void UnderAttackHealthBar::init()
Index: /code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.h
===================================================================
--- /code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.h	(revision 6053)
+++ /code/trunk/src/modules/overlays/hud/UnderAttackHealthBar.h	(revision 6054)
@@ -46,4 +46,5 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void changedOwner();
+            virtual void changedOverlayGroup();
 
             inline void setDescriptionPickPoint(const Vector2& pickpoint)
@@ -61,5 +62,5 @@
 
             PlayerInfo* owner_;
-            OverlayText* text_;
+            SmartPtr<OverlayText> text_;
             Timer inittimer_;
     };
Index: /code/trunk/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- /code/trunk/src/orxonox/overlays/OverlayGroup.cc	(revision 6053)
+++ /code/trunk/src/orxonox/overlays/OverlayGroup.cc	(revision 6054)
@@ -60,6 +60,7 @@
     OverlayGroup::~OverlayGroup()
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->destroy();
+        this->hudElements_.clear();
     }
 
@@ -83,5 +84,5 @@
     void OverlayGroup::setScale(const Vector2& scale)
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->scale(scale / this->scale_);
         this->scale_ = scale;
@@ -91,5 +92,5 @@
     void OverlayGroup::setScroll(const Vector2& scroll)
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->scroll(scroll - this->scroll_);
         this->scroll_ = scroll;
@@ -104,5 +105,5 @@
     void OverlayGroup::addElement(OrxonoxOverlay* element)
     {
-        hudElements_.insert(element);
+        hudElements_.insert(SmartPtr<OrxonoxOverlay>(element));
         element->setOverlayGroup( this );
         if (this->owner_)
@@ -120,5 +121,5 @@
     bool OverlayGroup::removeElement(OrxonoxOverlay* element)
     {
-        if(this->hudElements_.erase(element) == 0)
+        if(this->hudElements_.erase(SmartPtr<OrxonoxOverlay>(element)) == 0)
             return false;
         return true;
@@ -130,8 +131,8 @@
         if (index < this->hudElements_.size())
         {
-            std::set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
+            std::set< SmartPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin();
             for (unsigned int i = 0; i != index; ++it, ++i)
                 ;
-            return (*it);
+            return it->get();
         }
         else
@@ -144,5 +145,5 @@
         SUPER( OverlayGroup, changedVisibility );
         
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed
     }
@@ -152,5 +153,5 @@
         this->owner_ = owner;
 
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->setOwner(owner);
     }
Index: /code/trunk/src/orxonox/overlays/OverlayGroup.h
===================================================================
--- /code/trunk/src/orxonox/overlays/OverlayGroup.h	(revision 6053)
+++ /code/trunk/src/orxonox/overlays/OverlayGroup.h	(revision 6054)
@@ -64,5 +64,5 @@
         static void scrollGroup(const std::string& name, const Vector2& scroll);
 
-        inline const std::set<OrxonoxOverlay*>& getOverlays() const
+        inline const std::set< SmartPtr<OrxonoxOverlay> >& getOverlays() const
             { return this->hudElements_; }
 
@@ -90,5 +90,5 @@
 
     private:
-        std::set<OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
+        std::set< SmartPtr<OrxonoxOverlay> > hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
         Vector2 scale_;                            //!< Current scale (independent of the elements).
         Vector2 scroll_;                           //!< Current scrolling offset.
