Index: code/branches/presentation2012merge/src/modules/tetris/Tetris.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/Tetris.cc	(revision 9325)
+++ code/branches/presentation2012merge/src/modules/tetris/Tetris.cc	(revision 9326)
@@ -95,9 +95,21 @@
     void Tetris::cleanup()
     {
-        /*for(int i = 0;i < this->stones_.size(); i++) //TODO: Why isn't there any code like this
-        {                                              // compensating the 'new' statement?
-            delete this->stones_[i];
-        }//*/
-
+        if (this->isInitialized())
+        {
+            if (this->activeBrick_)
+            {
+                this->activeBrick_->destroy();
+                this->activeBrick_ = NULL;
+            }
+            if (this->futureBrick_)
+            {
+                this->futureBrick_->destroy();
+                this->futureBrick_ = NULL;
+            }
+
+            for (std::list<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+                (*it)->destroy();
+            this->stones_.clear();
+        }
     }
 
@@ -111,11 +123,14 @@
             if(!this->isValidBrickPosition(this->activeBrick_, this->activeBrick_->getPosition()))
             {
+                for (unsigned int i = 0; i < this->activeBrick_->getNumberOfStones(); i++)
+                    this->stones_.push_back(this->activeBrick_->getStone(i));
                 this->activeBrick_->setVelocity(Vector3::ZERO);
                 this->activeBrick_->releaseStones(this->center_);
-                //delete this->activeBrick_; //releasing the memory
                 this->findFullRows();
                 if(this->endGameCriteria_ < 0.1f) //end game if two bricks are created within a 0.1s interval.
+                {
                     this->end();
-                this->createBrick();
+                    return;
+                }
                 this->startBrick();
                 this->endGameCriteria_ = 0.0f;
@@ -133,9 +148,6 @@
             return false;
 
-        for(std::vector<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
-        {
-            if(stone == *it)
-                continue;
-
+        for(std::list<TetrisStone*>::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        {
             const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
 
@@ -189,8 +201,6 @@
 
         // we use a reverse iterator because we have to check for collisions with the topmost stones first
-        for(std::vector<TetrisStone*>::const_reverse_iterator it = this->stones_.rbegin(); it != this->stones_.rend(); ++it)
-        {
-            if(this->activeBrick_->contains(*it))//skip the moving brick' stones
-                continue;
+        for(std::list<TetrisStone*>::const_reverse_iterator it = this->stones_.rbegin(); it != this->stones_.rend(); ++it)
+        {
             //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount());
             const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
@@ -264,6 +274,4 @@
         if (this->center_ != NULL) // There needs to be a TetrisCenterpoint, i.e. the area the game takes place.
         {
-            // Create the futureBrick_
-            this->createBrick();
             // Create the first brick.
             this->createBrick();
@@ -350,28 +358,26 @@
             cameraIndex = this->activeBrick_->getCurrentCameraIndex();
             this->player_->stopControl();
+            // destroy old active brick
+            this->activeBrick_->destroy();
         }
 
         // Make the last brick to be created the active brick.
-        this->activeBrick_ = this->bricks_.back();
-
+        this->activeBrick_ = this->futureBrick_;
+        this->futureBrick_ = NULL;
+
+        // set its position
         this->player_->startControl(this->activeBrick_);
+        float xPos = (this->center_->getWidth()/2 + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
+        float yPos = (this->center_->getHeight()-0.5f)*this->center_->getStoneSize();
+        this->activeBrick_->setPosition(xPos, yPos, 0.0f);
         this->activeBrick_->setVelocity(0.0f, -this->center_->getStoneSpeed(), 0.0f);
         this->activeBrick_->setCameraPosition(cameraIndex);
+
+        // create a new future brick
+        this->createBrick();
     }
 
     void Tetris::createBrick(void)             //TODO: random rotation offset between 0 and 3 (times 90°)
     {
-        // Use the futureBrick_ as new currentBrick by setting its position and storing it in this->bricks
-        if(this->futureBrick_ != NULL)
-        {
-            for (unsigned int i = 0; i < this->futureBrick_->getNumberOfStones(); i++)
-            {
-                this->stones_.push_back(this->futureBrick_->getStone(i));
-            }
-            float xPos = (this->center_->getWidth()/2 + ((this->center_->getWidth() % 2)*2-1)/2.0f)*this->center_->getStoneSize();
-            float yPos = (this->center_->getHeight()-0.5f)*this->center_->getStoneSize();
-            this->futureBrick_->setPosition(xPos, yPos, 0.0f);
-            this->bricks_.push_back(this->futureBrick_);
-        }
         // create new futureBrick_
         this->futureBrick_ = new TetrisBrick(this->center_);
@@ -426,7 +432,8 @@
         {
             stonesPerRow = 0;
-            for(std::vector<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
-            {
-                correctPosition = static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize());
+            for(std::list<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); )
+            {
+                std::list<TetrisStone*>::iterator it_temp = it++;
+                correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize());
                 if(correctPosition == row)
                 {
@@ -447,15 +454,19 @@
     void Tetris::clearRow(unsigned int row)
     {// clear the full row
-        for(std::vector<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        for(std::list<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); )
         {
             if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)
-                (*it)->setPosition(Vector3(-50,-50,100));
-                //{(*it)->destroy(); this->stones_.erase(it); orxout()<< "destroy row "<<endl;}//experimental
+            {
+                (*it)->destroy();
+                this->stones_.erase(it++);
+            }
+            else
+                ++it;
         }
       // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
-        for(std::vector<TetrisStone*>::iterator it2 = this->stones_.begin(); it2 != this->stones_.end(); ++it2)
-        {
-            if(static_cast<unsigned int>(((*it2)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
-                (*it2)->setPosition((*it2)->getPosition()-Vector3(0,10,0));
+        for(std::list<TetrisStone*>::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        {
+            if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
+                (*it)->setPosition((*it)->getPosition()-Vector3(0,10,0));
         }
 
Index: code/branches/presentation2012merge/src/modules/tetris/Tetris.h
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/Tetris.h	(revision 9325)
+++ code/branches/presentation2012merge/src/modules/tetris/Tetris.h	(revision 9326)
@@ -56,5 +56,5 @@
         public:
             Tetris(BaseObject* creator); //!< Constructor. Registers and initializes the object.
-            virtual ~Tetris(); //!< Destructor. Cleans up, if initialized.           
+            virtual ~Tetris(); //!< Destructor. Cleans up, if initialized.
 
             virtual void start(void); //!< Starts the Tetris minigame.
@@ -88,14 +88,12 @@
             void clearRow(unsigned int row);
 
-            
+
             PlayerInfo* player_;
 
             WeakPtr<TetrisCenterpoint> center_; //!< The playing field.
-            std::vector<TetrisBrick*> bricks_; //!< A list of all bricks in play.
-            std::vector<TetrisStone*> stones_; //!< A list of all stones in play.
-            std::vector< std::vector<bool> > grid_;
+            std::list<TetrisStone*> stones_; //!< A list of all stones in play.
             TetrisBrick* activeBrick_;
             TetrisBrick* futureBrick_;
-            
+
             Timer starttimer_; //!< A timer to delay the start of the game.
             float endGameCriteria_; //<! Works as a timer which is resetted, whenever a brick is created.
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.cc	(revision 9325)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.cc	(revision 9326)
@@ -175,14 +175,4 @@
         return NULL;
     }
-//TODO: refactor this function; is not needed if brickstones are added to Tetris::stones_ after collision.
-    bool TetrisBrick::contains(TetrisStone* stone)
-    {
-        for(unsigned int i = 0; i < brickStones_.size(); i++)
-        {
-            if(stone == brickStones_[i])
-                return true;
-        }
-        return false;
-    }
 
     /**
Index: code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.h
===================================================================
--- code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.h	(revision 9325)
+++ code/branches/presentation2012merge/src/modules/tetris/TetrisBrick.h	(revision 9326)
@@ -65,5 +65,4 @@
                 { return this->brickStones_.size(); }
             TetrisStone* getStone(unsigned int i);
-            bool contains(TetrisStone* stone);
 
             void setGame(Tetris* tetris)
