Index: orxonox/trunk/src/array.cc
===================================================================
--- orxonox/trunk/src/array.cc	(revision 2864)
+++ orxonox/trunk/src/array.cc	(revision 2866)
@@ -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/src/object.cc
===================================================================
--- orxonox/trunk/src/object.cc	(revision 2864)
+++ orxonox/trunk/src/object.cc	(revision 2866)
@@ -119,5 +119,5 @@
 
 /**
-   \brief finalizes an Object.
+  \brief finalizes an Object.
    This funcion is needed, to close the glList and all the other lists.
 */
@@ -226,6 +226,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 )
     {
@@ -246,5 +247,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();
@@ -256,9 +258,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;
@@ -266,4 +280,5 @@
   delete group->vTexture;
 }
+
 /**
    \brief Reads in the .obj File and sets all the Values.
@@ -330,4 +345,5 @@
     }
   OBJ_FILE->close();
+  return true;
 
 }
@@ -370,4 +386,5 @@
 
   readingVertices = false;
+  currentGroup->faceCount++;
   char subbuffer1[20];
   char subbuffer2[20];
@@ -423,5 +440,5 @@
 {
   if (verbose >=3)
-    printf ("importing grafical Element.... including to openGL\n");
+    printf ("importing grafical Element to openGL\n");
   char* vertex = elementString;
 
@@ -430,4 +447,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);
 
@@ -440,4 +459,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);
 
@@ -488,23 +509,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/src/object.h
===================================================================
--- orxonox/trunk/src/object.h	(revision 2864)
+++ orxonox/trunk/src/object.h	(revision 2866)
@@ -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);
 
 
