Index: orxonox/trunk/importer/array.cc
===================================================================
--- orxonox/trunk/importer/array.cc	(revision 2860)
+++ orxonox/trunk/importer/array.cc	(revision 2863)
@@ -69,4 +69,5 @@
     printf ("Finalizing array.\n");  
   if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL)
+  //  if ((array = new GLfloat [entryCount]) == NULL)
     printf ("could not allocate %i data Blocks\n", entryCount);
   Entry* walker = firstEntry;
@@ -77,4 +78,5 @@
     }
   finalized = true;
+
   return;
 }
@@ -91,9 +93,9 @@
 	printf ("adding new Entry to Array: %f\n", entry);
       
-      entryCount++;
       currentEntry->value = entry;
       currentEntry->next = new Entry;
       currentEntry = currentEntry->next;
       currentEntry->next = NULL;
+      ++entryCount;
     }
   else 
Index: orxonox/trunk/importer/framework.cc
===================================================================
--- orxonox/trunk/importer/framework.cc	(revision 2860)
+++ orxonox/trunk/importer/framework.cc	(revision 2863)
@@ -2,5 +2,5 @@
 #include "object.h"
 
-int verbose = 2;
+int verbose = 1;
 WindowHandler wHandler;  // Create an instance of the whandler basecode class
 Object* obj;
@@ -74,9 +74,9 @@
       switch (event.type) {
         // If a quit event was recieved
-        case SDL_QUIT:
-          // then we're done and we'll end this program
+      case SDL_QUIT:
+	// then we're done and we'll end this program
           done=TRUE;
           break;
-        default:
+      default:
           break;
       }
Index: orxonox/trunk/importer/object.cc
===================================================================
--- orxonox/trunk/importer/object.cc	(revision 2860)
+++ orxonox/trunk/importer/object.cc	(revision 2863)
@@ -117,5 +117,5 @@
 
 /**
-   \brief finalizes an Object.
+  \brief finalizes an Object.
    This funcion is needed, to close the glList and all the other lists.
 */
@@ -224,6 +224,7 @@
   if (verbose >= 2)
     printf("Adding new Group\n");
+  group->name = "";
   group->faceMode = -1;
-  group->name = "";
+  group->faceCount =0;  
   if ((group->listNumber = glGenLists(1)) == 0 )
     {
@@ -244,5 +245,6 @@
       group->firstVertexTexture = currentGroup->firstVertexTexture + currentGroup->vTexture->getCount()/2;
     }
-
+  if (verbose >=2)
+    printf ("Creating new Arrays, with starting points v:%i, vt:%i, vn:%i .\n", group->firstVertex, group->firstVertexTexture, group->firstNormal);
   group->vertices = new Array();
   group->normals = new Array();
@@ -254,9 +256,21 @@
 /**
    \brief finalizes a Group.
+   \param group the group to finalize.
 */
 bool Object::finalizeGroup(Group* group)
 {
+  if (verbose >=2)
+    printf ("Finalize group %s.\n", group->name);
   glEnd();
   glEndList();
+}
+/**
+   \brief deletes the Arrays of the Group to save space.
+   \param group the group to delete the arrays from.
+*/
+bool Object::cleanupGroup(Group* group)
+{
+  if (verbose >=2)
+    printf ("cleaning up group %s.\n", group->name);
   
   delete group->vertices;
@@ -264,4 +278,5 @@
   delete group->vTexture;
 }
+
 /**
    \brief Reads in the .obj File and sets all the Values.
@@ -328,4 +343,5 @@
     }
   OBJ_FILE->close();
+  return true;
 
 }
@@ -368,4 +384,5 @@
 
   readingVertices = false;
+  currentGroup->faceCount++;
   char subbuffer1[20];
   char subbuffer2[20];
@@ -421,5 +438,5 @@
 {
   if (verbose >=3)
-    printf ("importing grafical Element.... including to openGL\n");
+    printf ("importing grafical Element to openGL\n");
   char* vertex = elementString;
 
@@ -428,4 +445,6 @@
   texture[0] = '\0';
   texture ++;
+  if (verbose>=3)
+    printf ("includeing texture #%i, and mapping it to group texture #%i, textureArray has %i entries.\n", atoi(texture), (atoi(texture)-1 - currentGroup->firstVertexTexture)*3, currentGroup->vTexture->getCount());
   glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
 
@@ -438,4 +457,6 @@
       glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
     }
+  if (verbose>=3)
+    printf ("includeing vertex #%i, and mapping it to group vertex #%i, vertexArray has %i entries.\n", atoi(vertex), (atoi(vertex)-1 - currentGroup->firstVertex)*3, currentGroup->vertices->getCount());
   glVertex3fv(currentGroup->vertices->getArray() +(atoi(vertex)-1 - currentGroup->firstVertex)*3);
 
@@ -486,23 +507,22 @@
 bool Object::readGroup (char* groupString)
 {
-  //  printf ("test\n");
-  if (!strcmp(groupString, "default"))
-    {
-      if (groupCount != 0)
-	{
-	  Group* newGroup = new Group;
-	  finalizeGroup(currentGroup);
-	  currentGroup->nextGroup = newGroup;
-	  initGroup(newGroup);
-	  currentGroup = newGroup; // must be after init see initGroup for more info
-	}
-      ++groupCount;
-    }
-  else
-    {
-      
-      currentGroup->name = new char [strlen(groupString)];      
+  // setting the group name if not default.
+  if (strcmp(currentGroup->name, "default"))
+    {
+      currentGroup->name = (char*) malloc ( strlen(groupString) * sizeof (char));
       strcpy(currentGroup->name, groupString);
     }
+  if (groupCount != 0 && currentGroup->faceCount>0)
+    {
+      Group* newGroup = new Group;
+      finalizeGroup(currentGroup);
+      currentGroup->nextGroup = newGroup;
+      initGroup(newGroup);
+      cleanupGroup(currentGroup); // deletes the arrays of the group; must be after initGroup.
+      currentGroup = newGroup; // must be after init see initGroup for more info
+    }
+
+  ++groupCount;
+
 }
 
Index: orxonox/trunk/importer/object.h
===================================================================
--- orxonox/trunk/importer/object.h	(revision 2860)
+++ orxonox/trunk/importer/object.h	(revision 2863)
@@ -49,4 +49,5 @@
     Array* vTexture;
     int faceMode;
+    int faceCount;
 
     int firstVertex;
@@ -74,4 +75,5 @@
   bool initGroup(Group* group);
   bool finalizeGroup (Group* group);
+  bool cleanupGroup(Group* group);
 
 
Index: orxonox/trunk/importer/toDo
===================================================================
--- orxonox/trunk/importer/toDo	(revision 2863)
+++ orxonox/trunk/importer/toDo	(revision 2863)
@@ -0,0 +1,6 @@
+toDO list for orxonox/importer:
+
+groupName is set on the wrong place, if set on the right programm will kill itself.
+
+ray03.obj from nomenes gives back a free, that has no reference.
+
