Index: trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 8992)
+++ trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 9003)
@@ -23,4 +23,5 @@
 #include "world_entity.h"
 #include "cr_physics_ground_walk.h"
+#include "collision_reaction.h"
 
 #include <vector>
@@ -58,23 +59,7 @@
 void CRPhysicsGroundWalk::reactToCollision(Collision* collision)
 {
-  CollisionEvent* ce = collision->getCollisionEvents().front();
-  Vector normal = ce->getGroundNormal();
-  // normal.normalize();
-
-  // put it back
-  //   PRINTF(0)("putting it back to lastPos: \n");
-  //   this->lastPositions[0].debug();
-  //   PRINTF(0)("current pos:\n");
-  //   collision->getEntityB()->getAbsCoor().debug();
-
-  float height;
+
   AABB* box = collision->getEntityB()->getModelAABB();
   WorldEntity* entity = collision->getEntityB();
-
-  // collision position maths
-  Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
-
-  float CR_MAX_WALK_HEIGHT = 2.0f;
-  float CR_THRESHOLD = 0.2f;
 
   if( box == NULL)
@@ -85,32 +70,90 @@
 
 
-  switch( ce->getType())
+  float CR_MAX_WALK_HEIGHT = 2.0f;
+  float CR_THRESHOLD = 0.2f;
+
+  float height = 0;
+  float front = 0;
+  float side = 0;
+
+  //PRINTF(0)("collision raction======================================\n");
+
+  const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents());
+  std::vector<CollisionEvent*>::const_iterator it = collisionEvents->begin();
+  for(; it != collisionEvents->end(); it++)
   {
-    case COLLISION_TYPE_AXIS_Y:
-
-      height = collPos.y - box->halfLength[1];
-     // PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
-     // PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
-
-      // object is beneath the plane (ground)
-      if( height <= 0.0f )
-      {
-        entity->shiftCoor(Vector(0, -height, 0));
-      }
-      // object is already in the wall
-      else if( ce->isInWall())
-      {
-        entity->setAbsCoor(entity->getLastAbsCoor());
-      }
-      break;
-
-
-    case COLLISION_TYPE_AXIS_X:
-    case COLLISION_TYPE_AXIS_Z:
-      break;
-
-    }
-
-
+
+    CollisionEvent* ce = (*it);
+    Vector normal = ce->getGroundNormal();
+
+    // calculate the collision position
+    Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
+
+    // test the 3 axis differently
+    switch( ce->getType())
+    {
+        // collision in the x-axis
+      case COLLISION_TYPE_AXIS_X:
+        front = collPos.x - box->halfLength[0]; // should be [0]
+
+        // object is beneath the plane (ground)
+        if( front <= 0.0f )
+        {
+          Vector backoff = entity->getAbsDirX() * front;
+//           entity->shiftCoor(backoff);
+        }
+        // object is already in the wall
+        else if( ce->isInWall())
+        {
+//           entity->setAbsCoor(entity->getLastAbsCoor());
+        }
+        break;
+
+
+        // collision in the y-axis
+      case COLLISION_TYPE_AXIS_Y:
+        // calulate the height above ground
+        height = collPos.y - box->halfLength[1];
+
+
+        // object is beneath the plane (ground)
+        if( height <= 0.0f )
+        {
+          entity->shiftCoor(Vector(0.0f, -height, 0.0f));
+          entity->setOnGround(true);
+        }
+        // object is already in the wall
+        else if( ce->isInWall())
+        {
+          entity->setAbsCoor(entity->getLastAbsCoor());
+        }
+        else
+        {
+          // entity is not on ground
+          entity->setOnGround(false);
+        }
+        break;
+
+
+        // collision in the z-axis
+      case COLLISION_TYPE_AXIS_Z:
+
+        side = collPos.z - box->halfLength[2]; // should be [2]
+
+        // object is beneath the plane (ground)
+        if( side <= 0.0f )
+        {
+          Vector backoff = entity->getAbsDirX() * side;
+//           entity->shiftCoor(backoff);
+        }
+        // object is already in the wall
+        else if( ce->isInWall())
+        {
+//           entity->setAbsCoor(entity->getLastAbsCoor());
+        }
+        break;
+    }
+  }
+  //PRINTF(0)("collision distances: x: %f, y: %f, z: %f\n", front, height, side);
 
 
@@ -126,17 +169,21 @@
 
 
-  if( box != NULL) {
-
-
-    if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
+  if( box != NULL)
+  {
+
+
+    if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f)
+    {
       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
       return;
     }
-    if(ce->getCollisionPosition().z <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
+    if(ce->getCollisionPosition().z <= 0.9 && ce->getGroundNormal().len() <= 1.4f)
+    {
       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
       return;
     }
 
-    if(ce->getGroundNormal().len() <= 0.1f) {
+    if(ce->getGroundNormal().len() <= 0.1f)
+    {
       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
       return;
@@ -144,5 +191,6 @@
 
 
-    if(ce->getGroundNormal().len() >= 1.4f) {
+    if(ce->getGroundNormal().len() >= 1.4f)
+    {
       downspeed++;
       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
@@ -164,5 +212,6 @@
 
     }
-    else {
+    else
+    {
       if(height.y <  box->halfLength[1] + 0.0f   /* && height.y  >  - 55.0f*/) // below ground
       {
@@ -194,7 +243,5 @@
  */
 void CRPhysicsGroundWalk::update(WorldEntity* owner)
-{
-
-}
-
-
+{}
+
+
Index: trunk/src/lib/graphics/importer/bsp_file.cc
===================================================================
--- trunk/src/lib/graphics/importer/bsp_file.cc	(revision 8992)
+++ trunk/src/lib/graphics/importer/bsp_file.cc	(revision 9003)
@@ -46,4 +46,39 @@
 BspFile::BspFile()
 {}
+
+BspFile::~ BspFile()
+{
+  delete [] nodes;
+  delete [] leaves;
+  delete [] planes;
+  delete [] bspModels;
+  delete [] leafFaces;
+  delete [] faces;
+  delete [] leafBrushes;
+  delete [] brushes;
+  delete [] brushSides;
+  delete [] vertice;
+  delete [] meshverts;
+  delete [] visData;
+  delete [] textures;
+  delete [] patchVertice;
+  delete [] patchIndexes;
+ // delete [] patchTrianglesPerRow;
+  delete [] lightMaps;
+  
+  for(int i = 0; i < this->numPatches; ++i) delete this->VertexArrayModels[i];
+ // delete  [] VertexArrayModels;
+  
+  for(int i = 0; i < this->numTextures; ++i)
+  {
+    delete this->Materials[i].mat;
+    //delete this->Materials[i].aviMat;
+  }
+  delete [] this->Materials;
+  //delete [] testSurf;
+  
+  
+  
+}
 
 /**
@@ -294,5 +329,5 @@
     this->patchVertice = new char[8*8*44*(this->numPatches+10)];
     this->patchIndexes = new char[7*8*2*4*(this->numPatches+10)];
-    this->patchRowIndexes = new int*[7*4*this->numPatches];
+ // this->patchRowIndexes = new int*[7*4*this->numPatches]; Not needed?
     this->patchTrianglesPerRow = new char[7*4*this->numPatches];
     this->VertexArrayModels  = new VertexArrayModel*[this->numPatches];
@@ -464,5 +499,5 @@
 
     if(File(absFileName).exists()) {
-      PRINTF(0)("BSP FILE: gefunden . \n");
+      PRINTF(4)("BSP FILE: gefunden . \n");
       this->Materials[i] = this->loadAVI(fileName);
       continue;
@@ -553,5 +588,5 @@
     }
 
-    PRINTF(0)("BSP FILE: Textur %s nicht  gefunden . \n", &this->textures[8+72*i]);
+    PRINTF(0)("BSP FILE: Texture %s not found.",&this->textures[8+ 72*i] );
     //  Default Material
     this->Materials[i].mat = new Material();
@@ -1012,6 +1047,6 @@
   Face->meshvert = patchOffset -sz;  //3*(patchOffset-sz)*level1*level1;
   Face->n_meshverts = sz;
-  PRINTF(4)("BSP FILE: sz: %i. \n", sz);
-  PRINTF(4)("BSP FILE: Face->meshvert %i . \n", Face->meshvert);
+  PRINTF(0)("BSP FILE: sz: %i. \n", sz);
+  PRINTF(0)("BSP FILE: Face->meshvert %i . \n", Face->meshvert);
 
   //Face->n_meshverts = sz;
Index: trunk/src/lib/graphics/importer/bsp_file.h
===================================================================
--- trunk/src/lib/graphics/importer/bsp_file.h	(revision 8992)
+++ trunk/src/lib/graphics/importer/bsp_file.h	(revision 9003)
@@ -151,4 +151,5 @@
 public:
   BspFile();
+  ~BspFile();
   int read(const char* name );
   void build_tree();
@@ -183,5 +184,5 @@
 
   int** patchRowIndexes;
-  VertexArrayModel** VertexArrayModels;
+  VertexArrayModel** VertexArrayModels; 
   int patchOffset;
 
Index: trunk/src/lib/graphics/importer/bsp_manager.cc
===================================================================
--- trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 8992)
+++ trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 9003)
@@ -1,19 +1,19 @@
 /*
    orxonox - the future of 3D-vertical-scrollers
- 
+
    Copyright (C) 2006 orx
- 
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2, or (at your option)
    any later version.
- 
+
    ### File Specific:
    main-programmer: bottac@ee.ethz.ch
- 
+
    Inspired by:
    Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
    Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
- 
+
    Collision detection adapted from:
    Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
@@ -69,18 +69,28 @@
 BspManager::BspManager(const TiXmlElement* root)
 {
- 
- 
+
+
   if( root != NULL)
     this->loadParams(root);
- 
+
   CDEngine::getInstance()->setBSPModel(this);
 } */
 
-void BspManager::load(const char* fileName, float scale)
+BspManager::~BspManager()
+{
+  if(this->bspFile)
+    delete this->bspFile;
+}
+
+int BspManager::load(const char* fileName, float scale)
 {
   // open a BSP file
+
+
   this->bspFile = new BspFile();
   this->bspFile->scale =  scale;
-  this->bspFile->read(ResourceManager::getFullName(fileName).c_str());
+  if(this->bspFile->read(ResourceManager::getFullName(fileName).c_str()) == -1)
+    return -1;
+
   this->bspFile->build_tree();
   this->root  = this->bspFile->get_root();
@@ -88,4 +98,6 @@
 
   this->outputFraction = 1.0f;
+
+  return 0;
 }
 /*
@@ -99,5 +111,5 @@
   this->root  = this->bspFile->get_root();
   this->alreadyVisible = new bool [this->bspFile->numFaces];
- 
+
   CDEngine::getInstance()->setBSPModel(this);
 }
@@ -962,5 +974,5 @@
   Vector dest = worldEntity->getAbsCoor() - upDir*40.0f; //
   Vector dest1 = position + forwardDir*4.0f;
-  Vector dest2 = position2 + forwardDir;
+  Vector dest2 = position2 + forwardDir*4.0;
   dest = position - Vector(0.0, 40.0,0.0);
   Vector out = dest;
@@ -974,13 +986,12 @@
 
   if( box != NULL) {
-    position = worldEntity->getAbsCoor() +  box->center; // + box->axis[1] * box->halfLength[1];
-    dest     = worldEntity->getAbsCoor() +  box->center - box->axis[1] * box->halfLength[1] * 40.0;
-
-    position1 = worldEntity->getAbsCoor() +  box->center + box->axis[0] * box->halfLength[0] * 2.0f;
-    dest1     = worldEntity->getAbsCoor() +  box->center - box->axis[0] * box->halfLength[0] *2.0f;
-
-
-    position2 = worldEntity->getAbsCoor() +  box->center + box->axis[2] * box->halfLength[2] * 2.0f;
-    dest2     = worldEntity->getAbsCoor() +  box->center - box->axis[2] * box->halfLength[2] * 2.0f;
+    position = worldEntity->getAbsCoor() +  box->center + Vector(0.0, 1.0, 0.0) * box->halfLength[1];
+    dest     = worldEntity->getAbsCoor() +  box->center - Vector(0.0, 1.0, 0.0) * (box->halfLength[1] + BSP_Y_OFFSET);
+
+    position1 = worldEntity->getAbsCoor() +  box->center - worldEntity->getAbsDirX() * (box->halfLength[0]  + BSP_X_OFFSET);
+    dest1     = worldEntity->getAbsCoor() +  box->center + worldEntity->getAbsDirX() * (box->halfLength[0]  + BSP_X_OFFSET);
+
+    position2 = worldEntity->getAbsCoor() +  box->center - worldEntity->getAbsDirZ() * (box->halfLength[2]  + BSP_Z_OFFSET);
+    dest2     = worldEntity->getAbsCoor() +  box->center + worldEntity->getAbsDirZ() * (box->halfLength[2]  + BSP_Z_OFFSET);
 
   } else {
@@ -989,4 +1000,8 @@
   }
 
+
+//   PRINTF(0)("x and v\n");
+//   worldEntity->getAbsDirX().debug();
+//   worldEntity->getAbsDirV().debug();
 
 
@@ -1035,8 +1050,7 @@
   plane* testPlane = this->collPlane;
 
-
   bool xCollision = false;
   bool zCollision = false;
-  if(!SolidFlag) {
+
 
     // 2nd Collision Detection
@@ -1048,16 +1062,23 @@
     this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
 
-    if(!this->outputAllSolid != 1.0f) {
+    if(this->outputFraction < 1.0f) {
       out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction;
+      dest1 = position1 + (dest1 -position1) * this->outputFraction;
       xCollision = true;
       testPlane = this->collPlane;
     }
-    if(this->outputAllSolid) {
+    if(this->outputAllSolid ) {
+
+      this->collPlane = new plane;
+      this->collPlane->x = 0.0f;
+      this->collPlane->y = 0.0f;
+      this->collPlane->z = 0.0f;
+      testPlane = this->collPlane;
       SolidFlag = true;
-      xCollision = true;  
+      xCollision = true;
     }
     //out.z = this->outputFraction;
 
-    if(!SolidFlag) {
+
 
       // 3rd Collision Detection
@@ -1067,19 +1088,27 @@
       this->inputStart =  position2;
       this->inputEnd =   dest2;
+
       this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
       //out.x = this->outputFraction;
 
-      if(this->outputFraction != 1.0f ) {
+      if(this->outputFraction < 1.0f ) {
         out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction;
+        dest2 = position2 + (dest2 -position2) * this->outputFraction;
         zCollision = true;
         testPlane = this->collPlane;
 
       }
-      if(this->outputAllSolid) {
-          SolidFlag = true;
-          zCollision = true;   
+      if(this->outputAllSolid ) {
+        this->collPlane = new plane;
+        this->collPlane->x = 0.0f;
+        this->collPlane->y = 0.0f;
+        this->collPlane->z = 0.0f;
+        testPlane = this->collPlane;
+
+        SolidFlag = true;
+        zCollision = true;
       }
-    }
-  }//end if
+
+  //end if
   /*
   This is how you would calculate the Coordinates where worldEntity Collided with the BSP world.
@@ -1091,13 +1120,14 @@
   // Return the normal here: Normal's stored in this->collPlane;
   if( collision) {
-    PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
-    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y || (xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0), this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
-  } else {
-    if(xCollision || zCollision) {
-
-      worldEntity->registerCollision((xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0) , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
-    }
-
-  }
+    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
+}
+  if(xCollision) {
+    worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z),dest1 , SolidFlag);
+  }
+  if(zCollision) {
+    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), dest2 , SolidFlag);
+  }
+
+
   //else  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false);
 
Index: trunk/src/lib/graphics/importer/bsp_manager.h
===================================================================
--- trunk/src/lib/graphics/importer/bsp_manager.h	(revision 8992)
+++ trunk/src/lib/graphics/importer/bsp_manager.h	(revision 9003)
@@ -28,4 +28,8 @@
 
 
+#define BSP_X_OFFSET 20.0f
+#define BSP_Y_OFFSET 40.0f
+#define BSP_Z_OFFSET 20.0f
+
 
 // FORWARD DECLARATIONS
@@ -41,4 +45,6 @@
 class WorldEntity;
 
+
+// Obsolete
 struct BspCollisionEvent
 {
@@ -54,7 +60,12 @@
 
   BspManager(const char* fileName, float scale = 0.4f);
-  void load(const char* fileName, float scale);
+
+  // Deconstructor
+  ~BspManager();
+
+
 
   // Functions
+  int load(const char* fileName, float scale);
   const void draw();
   const void tick(float time);
@@ -99,5 +110,5 @@
   Vector inputStart;
   Vector inputEnd;
-  
+
   Vector traceMins; //!< Mins of current bbox
   Vector traceMaxs; //!< Maxs of current bbox
@@ -112,8 +123,8 @@
   ::std::deque<int> opal; //!< the others here.
 
-  Vector out;  //!< For debugging only
+  Vector out;  //!< Stores collision coordinates
   Vector out1; //!< For debugging only
   Vector out2; //!< For debugging only
-                        
+
   int tgl;
 };
Index: trunk/src/lib/graphics/importer/interactive_model.h
===================================================================
--- trunk/src/lib/graphics/importer/interactive_model.h	(revision 8992)
+++ trunk/src/lib/graphics/importer/interactive_model.h	(revision 9003)
@@ -40,4 +40,6 @@
     virtual int getAnimation() = 0;
 
+    virtual bool isAnimationFinished() { return false; }
+
     virtual void setAnimationSpeed(float speed) {}
 };
Index: trunk/src/lib/graphics/importer/md2/md2Model.cc
===================================================================
--- trunk/src/lib/graphics/importer/md2/md2Model.cc	(revision 8992)
+++ trunk/src/lib/graphics/importer/md2/md2Model.cc	(revision 9003)
@@ -85,4 +85,5 @@
 
   this->scaleFactor = scale;
+  this->animationSpeed = 1.0f;
 
   shadeDots = MD2Model::anormsDots[0];
@@ -103,5 +104,4 @@
   this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor;
 
-  this->animationSpeed = 1.0f;
 
   // triangle conversion
Index: trunk/src/lib/graphics/importer/md2/md2Model.h
===================================================================
--- trunk/src/lib/graphics/importer/md2/md2Model.h	(revision 8992)
+++ trunk/src/lib/graphics/importer/md2/md2Model.h	(revision 9003)
@@ -161,4 +161,5 @@
   inline int MD2Model::getAnimation() { return this->animationState.type; }
   virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; }
+  virtual bool isAnimationFinished() { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
   /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
   void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
Index: trunk/src/lib/script_engine/script.cc
===================================================================
--- trunk/src/lib/script_engine/script.cc	(revision 8992)
+++ trunk/src/lib/script_engine/script.cc	(revision 9003)
@@ -24,4 +24,8 @@
 
 #include "class_list.h"
+// uncommet this when the std:string and the const bug is fixed
+//CREATE_SCRIPTABLE_CLASS(Script, CL_SCRIPT,
+//                               addMethod("addObject", ExecutorLua2<Script,std::string,std::string>(&Script::addObject))
+//                               ):
 
 Script::Script(const TiXmlElement* root)
@@ -73,5 +77,5 @@
 bool Script::loadFile(const std::string& filename)
  {
-
+   this->setName(filename);
    std::string filedest(ResourceManager::getInstance()->getDataDir());
    filedest += "scripts/" + filename;
@@ -93,4 +97,5 @@
      {
       currentFile = filename;
+      //this->addThisScript();
       return true;
      }
@@ -323,4 +328,15 @@
  }
 
+
+void Script::addThisScript()
+{
+  BaseObject* scriptClass = ClassList::getObject("Script", CL_SCRIPT_CLASS);
+   if (scriptClass != NULL)
+   {
+     static_cast<ScriptClass*>(scriptClass)->registerClass(this);
+     static_cast<ScriptClass*>(scriptClass)->insertObject(this, this,"thisscript", false);
+   }
+}
+
  int Script::reportError(int error)
  {
Index: trunk/src/lib/script_engine/script.h
===================================================================
--- trunk/src/lib/script_engine/script.h	(revision 8992)
+++ trunk/src/lib/script_engine/script.h	(revision 9003)
@@ -31,5 +31,5 @@
     void loadFileNoRet(const std::string& filename) { loadFile(filename); };
     bool loadFile(const std::string& filename);
-    void addObject(const std::string& className, const std::string& objectName);
+    void addObject( const std::string& className,const std::string& objectName);
 
     /// QUERRYING
@@ -61,5 +61,5 @@
 
   private:
-
+    void addThisScript();
     int  reportError(int error);                      //!< Get errormessage from the lua stack and print it.
     bool registerStandartClasses();                   //!< Register all the classes that the script might need
Index: trunk/src/lib/script_engine/script_class.h
===================================================================
--- trunk/src/lib/script_engine/script_class.h	(revision 8992)
+++ trunk/src/lib/script_engine/script_class.h	(revision 9003)
@@ -34,4 +34,5 @@
   virtual void registerClass(Script* script) = 0;
   virtual int insertObject(Script* L, BaseObject* obj, bool gc=false) = 0;
+  virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) = 0; 
 
   const ScriptMethod* scriptMethods() const { return this->_scriptMethods; }
@@ -64,4 +65,9 @@
     return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc);
   }
+
+  virtual int insertObject(Script* L, BaseObject* obj,const std::string& name, bool gc=false)
+  {
+    return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), name, gc);
+  }
 };
 
Index: trunk/src/lib/script_engine/script_manager.cc
===================================================================
--- trunk/src/lib/script_engine/script_manager.cc	(revision 8992)
+++ trunk/src/lib/script_engine/script_manager.cc	(revision 9003)
@@ -74,4 +74,9 @@
     while(!scripts->empty())
       delete scripts->front();
+  //Delete all triggers
+  if(this->getTriggers())
+    while(!triggers->empty())
+      delete triggers->front();
+  
 }
 
Index: trunk/src/lib/util/executor/executor_lua.cc
===================================================================
--- trunk/src/lib/util/executor/executor_lua.cc	(revision 8992)
+++ trunk/src/lib/util/executor/executor_lua.cc	(revision 9003)
@@ -37,3 +37,3 @@
 template<> void toLua<float>(lua_State* state, float value) { lua_pushnumber(state, (lua_Number) value); };
 template<> void toLua<char>(lua_State* state, char value) { lua_pushnumber(state, (lua_Number) value); };
-template<> void toLua<const std::string&>(lua_State* state, const std::string& value) {lua_pushstring (state, value.c_str()); }
+template<> void toLua<const std::string&>(lua_State* state, const std::string& value) { lua_pushstring (state, value.c_str()); }
