Index: trunk/src/lib/coord/p_node.cc
===================================================================
--- trunk/src/lib/coord/p_node.cc	(revision 5396)
+++ trunk/src/lib/coord/p_node.cc	(revision 5397)
@@ -415,5 +415,6 @@
     }
   child->parent = this;
-  this->children->add(child);
+  if (unlikely(this != NULL))
+    this->children->add(child);
   child->parentCoorChanged();
 }
Index: trunk/src/lib/graphics/graphics_engine.cc
===================================================================
--- trunk/src/lib/graphics/graphics_engine.cc	(revision 5396)
+++ trunk/src/lib/graphics/graphics_engine.cc	(revision 5397)
@@ -546,5 +546,5 @@
   GraphicsEngine::storeMatrices();
   Shader::suspendShader();
-  Render2D::getInstance()->draw(E2D_ALL_LAYERS);
+  Render2D::getInstance()->draw(E2D_LAYER_ALL);
   Shader::restoreShader();
   LightManager::getInstance()->draw();
Index: trunk/src/lib/graphics/render2D/element_2d.cc
===================================================================
--- trunk/src/lib/graphics/render2D/element_2d.cc	(revision 5396)
+++ trunk/src/lib/graphics/render2D/element_2d.cc	(revision 5397)
@@ -35,4 +35,5 @@
 {
   this->init();
+  Render2D::getInstance()->registerElement2D(this);
   this->setParent2D(NullElement2D::getInstance());
 }
@@ -48,4 +49,5 @@
 {
   this->init();
+  Render2D::getInstance()->registerElement2D(this);
 
   // check Parenting, and if ok parent the stuff
@@ -124,6 +126,4 @@
   this->toDirection = NULL;
   this->setSize2D(1,1);
-
-  Render2D::getInstance()->registerElement2D(this);
 }
 
@@ -471,5 +471,6 @@
     child->parentMode = parentingMode;
   child->parent = this;
-  this->children->add(child);
+  if (likely(this != NULL))
+    this->children->add(child);
   child->parentCoorChanged();
 }
@@ -667,5 +668,5 @@
 
 
-    if (this->alignment == E2D_ALIGN_SCREEN_CENTER && this->bRelCoorChanged)
+    if (unlikely(this->alignment & E2D_ALIGN_SCREEN_CENTER && this->bRelCoorChanged))
     {
       this->prevRelCoordinate = this->relCoordinate;
@@ -674,5 +675,5 @@
       this->absCoordinate.z = 0.0;
     }
-    else if (this->bindNode)
+    else if (unlikely(this->bindNode != NULL))
     {
       GLdouble projectPos[3];
Index: trunk/src/lib/graphics/render2D/element_2d.h
===================================================================
--- trunk/src/lib/graphics/render2D/element_2d.h	(revision 5396)
+++ trunk/src/lib/graphics/render2D/element_2d.h	(revision 5397)
@@ -21,13 +21,14 @@
 typedef enum
 {
-  E2D_BELOW_ALL                 =     1,        //!< Will be rendered below the 3D-scene. @todo make this work.
-  E2D_BOTTOM                    =     2,        //!< Will be rendered on the bottom Layer
-  E2D_MEDIUM                    =     4,        //!< Will be rendered on the medium Layer.
-  E2D_TOP                       =     8,        //!< Will be rendered on top of everything else
-
-  E2D_LAYER_COUNT               =     4         //!< The count of Layers.
+  E2D_BELOW_ALL,       //!< Will be rendered below the 3D-scene. @todo make this work.
+  E2D_BOTTOM,          //!< Will be rendered on the bottom Layer
+  E2D_MEDIUM,          //!< Will be rendered on the medium Layer.
+  E2D_TOP,             //!< Will be rendered on top of everything else
+
+  E2D_LAYER_COUNT,     //!< The count of Layers.
+
+  E2D_LAYER_ALL,
 } E2D_LAYER;
 #define E2D_DEFAULT_LAYER       E2D_TOP
-#define E2D_ALL_LAYERS          E2D_TOP | E2D_MEDIUM | E2D_BOTTOM | E2D_BELOW_ALL
 
 typedef enum
@@ -153,5 +154,5 @@
     void setParent2D (const char* parentName);
     /** @returns the parent of this Element2D */
-    inline Element2D* getParent () const { return this->parent; };
+    inline Element2D* getParent2D () const { return this->parent; };
     /** @returns the List of Children of this Element2D */
     inline const tList<Element2D>* getChildren2D() const { return this->children; };
Index: trunk/src/lib/graphics/render2D/render_2d.cc
===================================================================
--- trunk/src/lib/graphics/render2D/render_2d.cc	(revision 5396)
+++ trunk/src/lib/graphics/render2D/render_2d.cc	(revision 5397)
@@ -67,5 +67,5 @@
 {
   if (likely(element2D != NULL))
-    this->element2DList[(int)log2(E2D_DEFAULT_LAYER)]->add(element2D);
+    this->element2DList[E2D_DEFAULT_LAYER]->add(element2D);
 }
 
@@ -79,5 +79,5 @@
 void Render2D::unregisterElement2D(Element2D* element2D)
 {
-  this->element2DList[(int)log2(element2D->getLayer())]->remove(element2D);
+  this->element2DList[element2D->getLayer()]->remove(element2D);
 }
 
@@ -93,10 +93,10 @@
     return;
 
-  if (unlikely(pow(2, E2D_LAYER_COUNT ) > to))
+  if (E2D_LAYER_COUNT  > to)
     to = E2D_DEFAULT_LAYER;
   if (element2D->getLayer() != to)
   {
-    this->element2DList[(int)log2(element2D->getLayer())]->remove(element2D);
-    this->element2DList[(int)log2(to)]->add(element2D);
+    this->element2DList[element2D->getLayer()]->remove(element2D);
+    this->element2DList[to]->add(element2D);
   }
 }
@@ -124,6 +124,6 @@
 
 /**
- * renders all the Elements of the Render2D-engine
- * @param layer the Layer to draw
+ * renders all the Elements of the Render2D-engine's layer
+ * @param layer the Layer to draw (if E2D_LAYER_ALL then all layers will be drawn)
  */
 void Render2D::draw(unsigned int layer) const
@@ -131,11 +131,9 @@
   GraphicsEngine::enter2DMode();
 
-  int drawLayer = 1;
-
-  for (int i = 0; i < E2D_LAYER_COUNT; i++)
+  if (layer != E2D_LAYER_ALL)
   {
-    if (layer & drawLayer && this->element2DList[i]->getSize() > 0)
+    if ( this->element2DList[layer]->getSize() > 0)
     {
-      tIterator<Element2D>* iterator = this->element2DList[i]->getIterator();
+      tIterator<Element2D>* iterator = this->element2DList[layer]->getIterator();
       Element2D* elem = iterator->firstElement();
       while (elem != NULL)
@@ -147,5 +145,22 @@
       delete iterator;
     }
-    drawLayer << 1;
+  }
+  else  // if (layer != E2D_LAYER_ALL)
+  {
+    for (int i = 0; i < E2D_LAYER_COUNT; i++)
+    {
+      if (this->element2DList[i]->getSize() > 0)
+      {
+        tIterator<Element2D>* iterator = this->element2DList[i]->getIterator();
+        Element2D* elem = iterator->firstElement();
+        while (elem != NULL)
+        {
+          if (elem->isVisible())
+            elem->draw();
+          elem = iterator->nextElement();
+        }
+        delete iterator;
+      }
+    }
   }
   GraphicsEngine::leave2DMode();
Index: trunk/src/lib/graphics/render2D/render_2d.h
===================================================================
--- trunk/src/lib/graphics/render2D/render_2d.h	(revision 5396)
+++ trunk/src/lib/graphics/render2D/render_2d.h	(revision 5397)
@@ -15,23 +15,26 @@
 //! A default singleton class.
 class Render2D : public BaseObject {
+  friend class Element2D;
 
- public:
-  virtual ~Render2D();
-  /** @returns a Pointer to the only object of this Class */
-  inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
+  public:
+    virtual ~Render2D();
+    /** @returns a Pointer to the only object of this Class */
+    inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
 
-  void tick(float dt);
-  void draw(unsigned int layer) const;
+    void tick(float dt);
+    void draw(unsigned int layer) const;
 
-  void registerElement2D(Element2D* element2D);
-  void unregisterElement2D(Element2D* element2D);
-  void moveToLayer(Element2D* element2D, E2D_LAYER to);
 
- private:
-  Render2D();
-  static Render2D*              singletonRef;                    //!< Reference to this class.
+  private:
+    void registerElement2D(Element2D* element2D);
+    void unregisterElement2D(Element2D* element2D);
+    void moveToLayer(Element2D* element2D, E2D_LAYER to);
+
+
+    Render2D();
+    static Render2D*              singletonRef;                    //!< Reference to this class.
 
 //  tList<Element2D>*             element2DList;                   //!< List of all valid 2D-elements.
-  tList<Element2D>*             element2DList[E2D_LAYER_COUNT];  //!< List of all valid 2D-elements in the different Layers.
+    tList<Element2D>*             element2DList[E2D_LAYER_COUNT];  //!< List of all valid 2D-elements in the different Layers.
 };
 
Index: trunk/src/lib/gui/gl_gui/glgui_pushbutton.cc
===================================================================
--- trunk/src/lib/gui/gl_gui/glgui_pushbutton.cc	(revision 5396)
+++ trunk/src/lib/gui/gl_gui/glgui_pushbutton.cc	(revision 5397)
@@ -28,5 +28,4 @@
 {
   this->init();
-
 }
 
Index: trunk/src/lib/gui/gl_gui/glgui_widget.cc
===================================================================
--- trunk/src/lib/gui/gl_gui/glgui_widget.cc	(revision 5396)
+++ trunk/src/lib/gui/gl_gui/glgui_widget.cc	(revision 5397)
@@ -28,5 +28,4 @@
 {
   this->init();
-  this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
 }
 
@@ -50,4 +49,6 @@
   this->focusable = true;
   this->clickable = true;
+  this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
+  this->setParent2D((Element2D*)NULL);
 
   this->backMat = NULL;
Index: trunk/src/lib/shell/shell.cc
===================================================================
--- trunk/src/lib/shell/shell.cc	(revision 5396)
+++ trunk/src/lib/shell/shell.cc	(revision 5397)
@@ -285,5 +285,5 @@
   this->shellInput->setFont(this->fontFile, this->textSize);
   this->shellInput->setAlignment(TEXT_ALIGN_LEFT);
-  if (shellInput->getParent() != this)
+  if (shellInput->getParent2D() != this)
     this->shellInput->setParent2D(this);
 
Index: trunk/src/story_entities/world.cc
===================================================================
--- trunk/src/story_entities/world.cc	(revision 5396)
+++ trunk/src/story_entities/world.cc	(revision 5397)
@@ -468,5 +468,5 @@
   for(int i = 0; i < 100; i++)
   {
-    WorldEntity* tmp = new NPC2();
+    WorldEntity* tmp = new NPC();
     char npcChar[10];
     sprintf (npcChar, "NPC_%d", i);
