Index: trunk/src/lib/graphics/render2D/element_2d.cc
===================================================================
--- trunk/src/lib/graphics/render2D/element_2d.cc	(revision 5397)
+++ trunk/src/lib/graphics/render2D/element_2d.cc	(revision 5398)
@@ -113,5 +113,5 @@
   this->setActiveness(true);
   this->setAlignment(E2D_ALIGN_NONE);
-  this->layer = E2D_TOP;
+  this->layer = E2D_DEFAULT_LAYER;
   this->bindNode = NULL;
 
@@ -214,11 +214,11 @@
 {
   if (!strcmp(layer, "top"))
-    this->setLayer(E2D_TOP);
+    this->setLayer(E2D_LAYER_TOP);
   else if (!strcmp(layer, "medium"))
-    this->setLayer(E2D_MEDIUM);
+    this->setLayer(E2D_LAYER_MEDIUM);
   else if (!strcmp(layer, "bottom"))
-    this->setLayer(E2D_BOTTOM);
+    this->setLayer(E2D_LAYER_BOTTOM);
   else if (!strcmp(layer, "below-all"))
-    this->setLayer(E2D_BELOW_ALL);
+    this->setLayer(E2D_LAYER_BELOW_ALL);
 }
 
Index: trunk/src/lib/graphics/render2D/element_2d.h
===================================================================
--- trunk/src/lib/graphics/render2D/element_2d.h	(revision 5397)
+++ trunk/src/lib/graphics/render2D/element_2d.h	(revision 5398)
@@ -21,14 +21,14 @@
 typedef enum
 {
-  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_BELOW_ALL           =     0,        //!< Will be rendered below the 3D-scene. @todo make this work.
+  E2D_LAYER_BOTTOM              =     1,        //!< Will be rendered on the bottom Layer
+  E2D_LAYER_MEDIUM              =     2,        //!< Will be rendered on the medium Layer.
+  E2D_LAYER_TOP                 =     3,        //!< Will be rendered on top of everything else
+
+  E2D_LAYER_COUNT               =     4,         //!< The count of Layers.
+
+  E2D_LAYER_ALL                 =     5,
 } E2D_LAYER;
-#define E2D_DEFAULT_LAYER       E2D_TOP
+#define E2D_DEFAULT_LAYER       E2D_LAYER_MEDIUM
 
 typedef enum
@@ -81,5 +81,5 @@
     void setLayer(const char* layer);
     /** @returns the Layer this Element is drawn to */
-    inline E2D_LAYER getLayer() { return this->layer; };
+    inline E2D_LAYER getLayer() const { return this->layer; };
 
     /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
Index: trunk/src/lib/graphics/render2D/render_2d.cc
===================================================================
--- trunk/src/lib/graphics/render2D/render_2d.cc	(revision 5397)
+++ trunk/src/lib/graphics/render2D/render_2d.cc	(revision 5398)
@@ -14,5 +14,5 @@
 */
 
-//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
 
 #include "render_2d.h"
@@ -66,6 +66,7 @@
 void Render2D::registerElement2D(Element2D* element2D)
 {
-  if (likely(element2D != NULL))
-    this->element2DList[E2D_DEFAULT_LAYER]->add(element2D);
+  if (likely(element2D != NULL) && element2D->getLayer() < E2D_LAYER_COUNT)
+    this->element2DList[element2D->getLayer()]->add(element2D);
+  // DEBUG printf("::::%p, %d %d \n", element2D, element2D->getLayer(), this->element2DList[element2D->getLayer()]->getSize());
 }
 
@@ -79,5 +80,7 @@
 void Render2D::unregisterElement2D(Element2D* element2D)
 {
-  this->element2DList[element2D->getLayer()]->remove(element2D);
+  if (likely(element2D != NULL) && element2D->getLayer() < E2D_LAYER_COUNT)
+    this->element2DList[element2D->getLayer()]->remove(element2D);
+    // DEBUG  printf(":::%s layer: %d, %d\n", element2D->getClassName(), element2D->getLayer(), this->element2DList[element2D->getLayer()]->getSize());
 }
 
@@ -93,7 +96,7 @@
     return;
 
-  if (E2D_LAYER_COUNT  > to)
+  if (E2D_LAYER_COUNT  < to)
     to = E2D_DEFAULT_LAYER;
-  if (element2D->getLayer() != to)
+  if (likely(element2D->getLayer() != to))
   {
     this->element2DList[element2D->getLayer()]->remove(element2D);
@@ -127,5 +130,5 @@
  * @param layer the Layer to draw (if E2D_LAYER_ALL then all layers will be drawn)
  */
-void Render2D::draw(unsigned int layer) const
+void Render2D::draw(E2D_LAYER layer) const
 {
   GraphicsEngine::enter2DMode();
@@ -133,5 +136,5 @@
   if (layer != E2D_LAYER_ALL)
   {
-    if ( this->element2DList[layer]->getSize() > 0)
+    if (likely(this->element2DList[layer]->getSize() > 0))
     {
       tIterator<Element2D>* iterator = this->element2DList[layer]->getIterator();
Index: trunk/src/lib/graphics/render2D/render_2d.h
===================================================================
--- trunk/src/lib/graphics/render2D/render_2d.h	(revision 5397)
+++ trunk/src/lib/graphics/render2D/render_2d.h	(revision 5398)
@@ -23,5 +23,5 @@
 
     void tick(float dt);
-    void draw(unsigned int layer) const;
+    void draw(E2D_LAYER layer) const;
 
 
