Index: src/Legacy/oldmenu.cpp
===================================================================
--- src/Legacy/oldmenu.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/Legacy/oldmenu.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -1093,5 +1093,5 @@
     A++;
   }
-  delete(mol);
+  World::get()->destroyMolecule(mol);
 };
 
Index: src/World.cpp
===================================================================
--- src/World.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/World.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -47,11 +47,24 @@
   OBSERVE;
   molecule *mol = NULL;
-  mol = new molecule(periode);
-  molecules_deprecated->insert(mol);
+  mol = NewMolecule();
   assert(!molecules.count(currMoleculeId));
+  mol->setId(currMoleculeId++);
   // store the molecule by ID
-  molecules[currMoleculeId++] = mol;
+  molecules[mol->getId()] = mol;
   mol->signOn(this);
   return mol;
+}
+
+void World::destroyMolecule(molecule* mol){
+  OBSERVE;
+  destroyMolecule(mol->getId());
+}
+
+void World::destroyMolecule(moleculeId_t id){
+  OBSERVE;
+  molecule *mol = molecules[id];
+  assert(mol);
+  DeleteMolecule(mol);
+  molecules.erase(id);
 }
 
@@ -83,5 +96,5 @@
 }
 
-void World::destroyAtom(int id) {
+void World::destroyAtom(atomId_t id) {
   OBSERVE;
   atom *atom = atoms[id];
@@ -134,5 +147,5 @@
     currMoleculeId(0),
     periode(new periodentafel),
-    molecules_deprecated(new MoleculeListClass),
+    molecules_deprecated(new MoleculeListClass(this)),
     atoms(),
     molecules()
@@ -145,7 +158,12 @@
   delete molecules_deprecated;
   delete periode;
-  AtomSet::iterator iter;
-  for(iter=atoms.begin();iter!=atoms.end();++iter){
-    DeleteAtom((*iter).second);
+  MoleculeSet::iterator molIter;
+  for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
+    DeleteMolecule((*molIter).second);
+  }
+  molecules.clear();
+  AtomSet::iterator atIter;
+  for(atIter=atoms.begin();atIter!=atoms.end();++atIter){
+    DeleteAtom((*atIter).second);
   }
   atoms.clear();
Index: src/World.hpp
===================================================================
--- src/World.hpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/World.hpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -16,5 +16,5 @@
 #include <boost/shared_ptr.hpp>
 
-
+#include "defs.hpp"
 #include "Patterns/Observer.hpp"
 #include "Patterns/Cacheable.hpp"
@@ -40,7 +40,6 @@
 friend class ManipulateAtomsProcess;
 template<typename> friend class AtomsCalculation;
-
-typedef std::map<int,atom*> AtomSet;
-typedef std::map<int,molecule*> MoleculeSet;
+typedef std::map<atomId_t,atom*> AtomSet;
+typedef std::map<moleculeId_t,molecule*> MoleculeSet;
 public:
 
@@ -90,4 +89,7 @@
   molecule *createMolecule();
 
+  void destroyMolecule(molecule*);
+  void destroyMolecule(moleculeId_t);
+
   /**
    * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores
@@ -112,5 +114,5 @@
    * atom directly since this will leave the pointer inside the world.
    */
-  void destroyAtom(int);
+  void destroyAtom(atomId_t);
 
   /**
@@ -166,7 +168,7 @@
   periodentafel *periode;
   AtomSet atoms;
-  int currAtomId; //!< stores the next available Id for atoms
+  atomId_t currAtomId; //!< stores the next available Id for atoms
   MoleculeSet molecules;
-  int currMoleculeId;
+  moleculeId_t currMoleculeId;
 
 
Index: src/boundary.cpp
===================================================================
--- src/boundary.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/boundary.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -4,4 +4,5 @@
  */
 
+#include "World.hpp"
 #include "atom.hpp"
 #include "bond.hpp"
@@ -800,5 +801,5 @@
 {
 	Info FunctionInfo(__func__);
-  molecule *Filling = new molecule(filler->elemente);
+  molecule *Filling = World::get()->createMolecule();
   Vector CurrentPosition;
   int N[NDIM];
Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/builder.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -1432,5 +1432,5 @@
      }
      if (mol == NULL) {
-       mol = new molecule(periode);
+       mol = World::get()->createMolecule();
        mol->ActiveFlag = true;
        if (ConfigFileName != NULL)
@@ -1634,5 +1634,5 @@
                 Log() << Verbose(1) << "Filling Box with water molecules." << endl;
                 // construct water molecule
-                molecule *filler = new molecule(periode);
+                molecule *filler = World::get()->createMolecule();
                 molecule *Filling = NULL;
                 atom *second = NULL, *third = NULL;
@@ -1664,5 +1664,5 @@
                   molecules->insert(Filling);
                 }
-                delete(filler);
+                World::get()->destroyMolecule(filler);
                 argptr+=6;
               }
@@ -2203,4 +2203,6 @@
     if(World::get()->numMolecules() == 0){
         mol = World::get()->createMolecule();
+        World::get()->getMolecules()->insert(mol);
+        cout << "Molecule created" << endl;
         if(mol->cell_size[0] == 0.){
             Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
Index: src/config.cpp
===================================================================
--- src/config.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/config.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -851,5 +851,5 @@
 void config::Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
 {
-  molecule *mol = new molecule(periode);
+  molecule *mol = World::get()->createMolecule();
   ifstream *file = new ifstream(filename);
   if (file == NULL) {
@@ -1089,5 +1089,5 @@
 void config::LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
 {
-  molecule *mol = new molecule(periode);
+  molecule *mol = World::get()->createMolecule();
   ifstream *file = new ifstream(filename);
   if (file == NULL) {
@@ -1788,5 +1788,5 @@
   char filename[MAXSTRINGSIZE];
   ofstream output;
-  molecule *mol = new molecule(periode);
+  molecule *mol = World::get()->createMolecule();
   mol->SetNameFromFilename(ConfigFileName);
 
@@ -1899,5 +1899,5 @@
   }
 
-  delete(mol);
+  World::get()->destroyMolecule(mol);
 };
 
Index: src/defs.hpp
===================================================================
--- src/defs.hpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/defs.hpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -32,4 +32,8 @@
 
 enum Shading { white, lightgray, darkgray, black };  //!< color in Breadth-First-Search analysis
+
+// some types that can stay abstract
+typedef unsigned int moleculeId_t;
+typedef int atomId_t;
 
 //enum CutCyclicBond { KeepBond,  SaturateBond }; //!< Saturation scheme either atom- or bondwise 
Index: src/molecule.cpp
===================================================================
--- src/molecule.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/molecule.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -53,4 +53,8 @@
 };
 
+molecule *NewMolecule(){
+  return new molecule(World::get()->getPeriode());
+}
+
 /** Destructor of class molecule.
  * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
@@ -66,4 +70,8 @@
 
 
+void DeleteMolecule(molecule *mol){
+  delete mol;
+}
+
 // getter and setter
 const std::string molecule::getName(){
@@ -74,4 +82,12 @@
   OBSERVE;
   strncpy(name,_name.c_str(),MAXSTRINGSIZE);
+}
+
+moleculeId_t molecule::getId(){
+  return id;
+}
+
+void molecule::setId(moleculeId_t _id){
+  id =_id;
 }
 
Index: src/molecule.hpp
===================================================================
--- src/molecule.hpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/molecule.hpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -29,4 +29,5 @@
 #include <string>
 
+#include "defs.hpp"
 #include "graph.hpp"
 #include "stackclass.hpp"
@@ -85,4 +86,6 @@
  */
 class molecule : public PointCloud , public Observable {
+  friend molecule *NewMolecule();
+  friend void DeleteMolecule(molecule *);
   public:
     double cell_size[6];//!< cell size
@@ -108,14 +111,19 @@
   private:
     Cacheable<string> formula;
+    moleculeId_t id;
+  protected:
+    molecule(const periodentafel * const teil);
+    virtual ~molecule();
+
 
 public:
-  molecule(const periodentafel * const teil);
-  virtual ~molecule();
-
   //getter and setter
   const std::string getName();
+  moleculeId_t getId();
+  void setId(moleculeId_t);
   void setName(const std::string);
   const std::string getFormula();
   std::string calcFormula();
+
 
   // re-definition of virtual functions from PointCloud
@@ -321,4 +329,7 @@
 };
 
+molecule *NewMolecule();
+void DeleteMolecule(molecule* mol);
+
 #include "molecule_template.hpp"
 
@@ -330,5 +341,5 @@
     int MaxIndex;
 
-  MoleculeListClass();
+  MoleculeListClass(World *world);
   ~MoleculeListClass();
 
@@ -363,4 +374,5 @@
 
   private:
+  World *world; //!< The world this List belongs to. Needed to avoid deadlocks in the destructor
 };
 
Index: src/molecule_dynamics.cpp
===================================================================
--- src/molecule_dynamics.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/molecule_dynamics.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -6,4 +6,5 @@
  */
 
+#include "World.hpp"
 #include "atom.hpp"
 #include "config.hpp"
@@ -485,5 +486,5 @@
   bool status = true;
   int MaxSteps = configuration.MaxOuterStep;
-  MoleculeListClass *MoleculePerStep = new MoleculeListClass();
+  MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::get());
   // Get the Permutation Map by MinimiseConstrainedPotential
   atom **PermutationMap = NULL;
@@ -505,5 +506,5 @@
   Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl;
   for (int step = 0; step <= MaxSteps; step++) {
-    mol = new molecule(elemente);
+    mol = World::get()->createMolecule();
     MoleculePerStep->insert(mol);
     Walker = start;
Index: src/molecule_fragmentation.cpp
===================================================================
--- src/molecule_fragmentation.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/molecule_fragmentation.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -8,4 +8,5 @@
 #include <cstring>
 
+#include "World.hpp"
 #include "atom.hpp"
 #include "bond.hpp"
@@ -675,5 +676,5 @@
   //if (FragmentationToDo) {    // we should always store the fragments again as coordination might have changed slightly without changing bond structure
   // allocate memory for the pointer array and transmorph graphs into full molecular fragments
-  BondFragments = new MoleculeListClass();
+  BondFragments = new MoleculeListClass(World::get());
   int k=0;
   for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {
@@ -926,5 +927,5 @@
 {
   atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");
-  molecule *Leaf = new molecule(elemente);
+  molecule *Leaf = World::get()->createMolecule();
 
 //  Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl;
Index: src/moleculelist.cpp
===================================================================
--- src/moleculelist.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/moleculelist.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -7,4 +7,5 @@
 #include <cstring>
 
+#include "World.hpp"
 #include "atom.hpp"
 #include "bond.hpp"
@@ -24,5 +25,6 @@
 /** Constructor for MoleculeListClass.
  */
-MoleculeListClass::MoleculeListClass()
+MoleculeListClass::MoleculeListClass(World *_world) :
+  world(_world)
 {
   // empty lists
@@ -38,5 +40,5 @@
   for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
     Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl;
-    delete (*ListRunner);
+    world->destroyMolecule(*ListRunner);
   }
   Log() << Verbose(4) << "Freeing ListOfMolecules." << endl;
@@ -213,5 +215,5 @@
   // remove src
   ListOfMolecules.remove(srcmol);
-  delete(srcmol);
+  World::get()->destroyMolecule(srcmol);
   return true;
 };
@@ -748,5 +750,5 @@
 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
 {
-  molecule *mol = new molecule(periode);
+  molecule *mol = World::get()->createMolecule();
   atom *Walker = NULL;
   atom *Advancer = NULL;
@@ -773,5 +775,5 @@
     }
     // remove the molecule
-    delete(*MolRunner);
+    World::get()->destroyMolecule(*MolRunner);
     ListOfMolecules.erase(MolRunner);
   }
@@ -795,5 +797,5 @@
   molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules");
   for (int i=0;i<MolCount;i++) {
-    molecules[i] = (molecule*) new molecule(mol->elemente);
+    molecules[i] = World::get()->createMolecule();
     molecules[i]->ActiveFlag = true;
     strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE);
@@ -893,5 +895,5 @@
   OBSERVE;
   molecule *mol = NULL;
-  mol = new molecule(periode);
+  mol = World::get()->createMolecule();
   insert(mol);
 };
@@ -902,5 +904,5 @@
   char filename[MAXSTRINGSIZE];
   Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
-  mol = new molecule(periode);
+  mol = World::get()->createMolecule();
   do {
     Log() << Verbose(0) << "Enter file name: ";
@@ -960,5 +962,5 @@
       mol = *ListRunner;
       ListOfMolecules.erase(ListRunner);
-      delete(mol);
+      World::get()->destroyMolecule(mol);
       break;
     }
@@ -1007,5 +1009,5 @@
   // remove the leaf itself
   if (Leaf != NULL) {
-    delete (Leaf);
+    World::get()->destroyMolecule(Leaf);
     Leaf = NULL;
   }
Index: src/unittests/AnalysisCorrelationToPointUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -52,9 +52,9 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::get()->getPeriode();
   tafel->AddElement(hydrogen);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
+  TestMolecule = World::get()->createMolecule();
   Walker = World::get()->createAtom();
   Walker->type = hydrogen;
@@ -77,5 +77,5 @@
   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
 
-  TestList = new MoleculeListClass;
+  TestList = World::get()->getMolecules();
   TestMolecule->ActiveFlag = true;
   TestList->insert(TestMolecule);
@@ -98,10 +98,6 @@
     delete(binmap);
 
-  // remove
-  delete(TestList);
-  // note that all the atoms are cleaned by TestMolecule
   delete(point);
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::destroy();
 };
 
Index: src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -56,10 +56,10 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::get()->getPeriode();
   tafel->AddElement(hydrogen);
   tafel->AddElement(carbon);
 
   // construct molecule (tetraeder of hydrogens) base
-  TestMolecule = new molecule(tafel);
+  TestMolecule = World::get()->createMolecule();
   Walker = World::get()->createAtom();
   Walker->type = hydrogen;
@@ -82,5 +82,5 @@
   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
 
-  TestList = new MoleculeListClass;
+  TestList = World::get()->getMolecules();
   TestMolecule->ActiveFlag = true;
   TestList->insert(TestMolecule);
@@ -127,11 +127,8 @@
     delete(binmap);
 
-  // remove
-  delete(TestList);
   delete(Surface);
   // note that all the atoms are cleaned by TestMolecule
   delete(LC);
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::destroy();
 };
 
Index: src/unittests/AnalysisPairCorrelationUnitTest.cpp
===================================================================
--- src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -51,9 +51,9 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::get()->getPeriode();
   tafel->AddElement(hydrogen);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
+  TestMolecule = World::get()->createMolecule();
   Walker = World::get()->createAtom();
   Walker->type = hydrogen;
@@ -76,5 +76,5 @@
   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
 
-  TestList = new MoleculeListClass;
+  TestList = World::get()->getMolecules();
   TestMolecule->ActiveFlag = true;
   TestList->insert(TestMolecule);
@@ -94,9 +94,6 @@
     delete(binmap);
 
-  // remove
-  delete(TestList);
   // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::destroy();
 };
 
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/unittests/Makefile.am	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -30,5 +30,5 @@
   CacheableTest \
   DescriptorUnittest \
-  manipulateAtomsTest \ 
+  manipulateAtomsTest \
   atomsCalculationTest \
   ${MENUTESTS}
Index: src/unittests/analysisbondsunittest.cpp
===================================================================
--- src/unittests/analysisbondsunittest.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/unittests/analysisbondsunittest.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -57,10 +57,10 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::get()->getPeriode();
   tafel->AddElement(hydrogen);
   tafel->AddElement(carbon);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
+  TestMolecule = World::get()->createMolecule();
   Walker = World::get()->createAtom();
   Walker->type = hydrogen;
@@ -113,8 +113,7 @@
 
   // remove molecule
-  delete(TestMolecule);
+  World::get()->destroyMolecule(TestMolecule);
   // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::destroy();
 };
 
Index: src/unittests/bondgraphunittest.cpp
===================================================================
--- src/unittests/bondgraphunittest.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/unittests/bondgraphunittest.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -52,10 +52,10 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::get()->getPeriode();
   tafel->AddElement(hydrogen);
   tafel->AddElement(carbon);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
+  TestMolecule = World::get()->createMolecule();
   Walker = World::get()->createAtom();
   Walker->type = hydrogen;
@@ -97,8 +97,7 @@
 
   // remove molecule
-  delete(TestMolecule);
+  World::get()->destroyMolecule(TestMolecule);
   // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::destroy();
 };
 
Index: src/unittests/listofbondsunittest.cpp
===================================================================
--- src/unittests/listofbondsunittest.cpp	(revision 244d26586ddc827088fbe4ebefb4ab1e79777861)
+++ src/unittests/listofbondsunittest.cpp	(revision cbc5fbee9bc58a85fd5fabd2d6648d52abe180a2)
@@ -46,9 +46,9 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::get()->getPeriode();
   tafel->AddElement(hydrogen);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
+  TestMolecule = World::get()->createMolecule();
   Walker = World::get()->createAtom();
   Walker->type = hydrogen;
@@ -77,8 +77,7 @@
 {
   // remove
-  delete(TestMolecule);
+  World::get()->destroyMolecule(TestMolecule);
   // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::destroy();
 };
 
