Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision 920c708861f3c5528d44b9973722fa719f892ce0)
+++ src/builder.cpp	(revision 42af9ec72d1b004ed85b6db33bdcaeeecd94a23a)
@@ -1513,5 +1513,5 @@
   molecule *mol = NULL;
   string BondGraphFileName("\n");
-  strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
+  bool DatabasePathGiven = false;
 
   if (argc > 1) { // config file specified as option
@@ -1557,4 +1557,5 @@
               DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl);
               strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
+              DatabasePathGiven = true;
               argptr+=1;
             }
@@ -1600,11 +1601,12 @@
 
     // 3a. Parse the element database
-    if (periode->LoadPeriodentafel(configuration.databasepath)) {
-      DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
-      //periode->Output();
-    } else {
-      DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
-      return 1;
-    }
+    if (DatabasePathGiven)
+      if (periode->LoadPeriodentafel(configuration.databasepath)) {
+        DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
+        //periode->Output();
+      } else {
+        DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
+        return 1;
+      }
     // 3b. Find config file name and parse if possible, also BondGraphFileName
     if (argv[1][0] != '-') {
@@ -2522,9 +2524,4 @@
     Log() << Verbose(0) << "Saving to " << ConfigFileName << "." << endl;
     World::getInstance().getConfig()->SaveAll(ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules());
-    if(World::getInstance().getPeriode()->StorePeriodentafel(configuration->databasepath))
-        Log() << Verbose(0) << "Saving of elements.db successful." << endl;
-
-    else
-        Log() << Verbose(0) << "Saving of elements.db failed." << endl;
 
   // free the new argv
Index: src/config.cpp
===================================================================
--- src/config.cpp	(revision 920c708861f3c5528d44b9973722fa719f892ce0)
+++ src/config.cpp	(revision 42af9ec72d1b004ed85b6db33bdcaeeecd94a23a)
@@ -14,4 +14,5 @@
 #include "element.hpp"
 #include "helpers.hpp"
+#include "info.hpp"
 #include "lists.hpp"
 #include "log.hpp"
@@ -1712,4 +1713,5 @@
 bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const
 {
+  Info FunctionInfo(__func__);
   atom *Walker = NULL;
   ofstream *output = NULL;
@@ -1738,19 +1740,17 @@
 
   // create global to local id map
-  int **LocalNotoGlobalNoMap = new int *[MolList->ListOfMolecules.size()];
-  for (int i=0;i<MolList->ListOfMolecules.size();i++)
-    LocalNotoGlobalNoMap[i] = NULL;
+  map<int, int> LocalNotoGlobalNoMap;
   {
-    int MolCounter = 0;
-    int AtomNo = 0;
+    unsigned int MolCounter = 0;
+    int AtomNo = 1;
     for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
-      LocalNotoGlobalNoMap[MolCounter] = new int[MolList->CountAllAtoms()];
-      for (int i=0;i<MolList->CountAllAtoms();i++)
-        LocalNotoGlobalNoMap[MolCounter][i] = NULL;
-
-      (*MolWalker)->SetIndexedArrayForEachAtomTo( LocalNotoGlobalNoMap[MolCounter], &atom::nr, IncrementalAbsoluteValue, &AtomNo);
-
+      atom *Walker = (*MolWalker)->start;
+      while (Walker->next != (*MolWalker)->end) {
+        Walker = Walker->next;
+        LocalNotoGlobalNoMap.insert( pair<int,int>(Walker->getId(), AtomNo++) );
+      }
       MolCounter++;
     }
+    ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule");
   }
 
@@ -1763,5 +1763,5 @@
       while (Walker->next != (*MolWalker)->end) {
         Walker = Walker->next;
-        *output << AtomNo+1 << "\t";
+        *output << LocalNotoGlobalNoMap[ Walker->getId() ] << "\t";
         *output << Walker->getName() << "\t";
         *output << (*MolWalker)->name << "\t";
@@ -1771,5 +1771,5 @@
         *output << Walker->type->symbol << "\t";
         for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
-          *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ]+1 << "\t";
+          *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom(Walker)->getId() ] << "\t";
         for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
           *output << "-\t";
@@ -1786,7 +1786,4 @@
   delete(output);
   delete(fname);
-  for(size_t i=0;i<MolList->ListOfMolecules.size(); i++)
-    delete[](LocalNotoGlobalNoMap[i]);
-  delete[](LocalNotoGlobalNoMap);
 
   return true;
Index: src/molecule_fragmentation.cpp
===================================================================
--- src/molecule_fragmentation.cpp	(revision 920c708861f3c5528d44b9973722fa719f892ce0)
+++ src/molecule_fragmentation.cpp	(revision 42af9ec72d1b004ed85b6db33bdcaeeecd94a23a)
@@ -516,5 +516,4 @@
   int AtomNo = 0;
   SetIndexedArrayForEachAtomTo( SortIndex, &atom::nr, &IncrementalAbsoluteValue, AtomNo );
-  delete[](SortIndex);
 
   return true;
@@ -542,5 +541,4 @@
 {
   MoleculeListClass *BondFragments = NULL;
-  int *SortIndex = NULL;
   int *MinimumRingSize = new int[AtomCount];
   int FragmentCounter;
@@ -685,4 +683,5 @@
   if (BondFragments->ListOfMolecules.size() != 0) {
     // create the SortIndex from BFS labels to order in the config file
+    int *SortIndex = NULL;
     CreateMappingLabelsToConfigSequence(SortIndex);
 
@@ -718,5 +717,4 @@
     // free memory for bond part
     DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl);
-    delete[](FragmentList); // remove bond molecule from memory
     delete[](SortIndex);
   } else {
Index: src/periodentafel.cpp
===================================================================
--- src/periodentafel.cpp	(revision 920c708861f3c5528d44b9973722fa719f892ce0)
+++ src/periodentafel.cpp	(revision 42af9ec72d1b004ed85b6db33bdcaeeecd94a23a)
@@ -39,4 +39,5 @@
 /** destructor for class periodentafel
  * Removes every element and afterwards deletes start and end of list.
+ * TODO: Handle when elements have changed and store databases then
  */
 periodentafel::~periodentafel()
