Index: src/Actions/GraphAction/DepthFirstSearchAction.cpp
===================================================================
--- src/Actions/GraphAction/DepthFirstSearchAction.cpp	(revision ba94c53b55b13c65d4a227ddc75d8d7e657d9670)
+++ src/Actions/GraphAction/DepthFirstSearchAction.cpp	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
@@ -28,4 +28,5 @@
 #include "Graph/DepthFirstSearchAnalysis.hpp"
 #include "molecule.hpp"
+#include "MoleculeLeafClass.hpp"
 #include "Descriptors/MoleculeDescriptor.hpp"
 #include "Descriptors/MoleculeIdDescriptor.hpp"
Index: src/Fragmentation/Fragmentation.cpp
===================================================================
--- src/Fragmentation/Fragmentation.cpp	(revision ba94c53b55b13c65d4a227ddc75d8d7e657d9670)
+++ src/Fragmentation/Fragmentation.cpp	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
@@ -36,4 +36,5 @@
 #include "Graph/CheckAgainstAdjacencyFile.hpp"
 #include "molecule.hpp"
+#include "MoleculeLeafClass.hpp"
 #include "World.hpp"
 
Index: src/Graph/DepthFirstSearchAnalysis.cpp
===================================================================
--- src/Graph/DepthFirstSearchAnalysis.cpp	(revision ba94c53b55b13c65d4a227ddc75d8d7e657d9670)
+++ src/Graph/DepthFirstSearchAnalysis.cpp	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
@@ -33,4 +33,5 @@
 #include "Descriptors/AtomDescriptor.hpp"
 #include "molecule.hpp"
+#include "MoleculeLeafClass.hpp"
 #include "World.hpp"
 
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision ba94c53b55b13c65d4a227ddc75d8d7e657d9670)
+++ src/Makefile.am	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
@@ -172,4 +172,5 @@
   Formula.cpp \
   linkedcell.cpp \
+  MoleculeLeafClass.cpp \
   moleculelist.cpp \
   molecule.cpp \
@@ -195,4 +196,5 @@
   Formula.hpp \
   linkedcell.hpp \
+  MoleculeLeafClass.hpp \
   molecule.hpp \
   ThermoStatContainer.hpp \
Index: src/MoleculeLeafClass.cpp
===================================================================
--- src/MoleculeLeafClass.cpp	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
+++ src/MoleculeLeafClass.cpp	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
@@ -0,0 +1,244 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * MoleculeLeafClass.cpp
+ *
+ *  Created on: Oct 20, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "MoleculeLeafClass.hpp"
+
+#include "CodePatterns/Log.hpp"
+
+#include "atom.hpp"
+#include "Element/element.hpp"
+#include "Fragmentation/Graph.hpp"
+#include "Fragmentation/KeySet.hpp"
+#include "molecule.hpp"
+
+/** Constructor for MoleculeLeafClass root leaf.
+ * \param *Up Leaf on upper level
+ * \param *PreviousLeaf NULL - We are the first leaf on this level, otherwise points to previous in list
+ */
+//MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *Up = NULL, MoleculeLeafClass *Previous = NULL)
+MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL) :
+  Leaf(NULL),
+  previous(PreviousLeaf)
+{
+  //  if (Up != NULL)
+  //    if (Up->DownLeaf == NULL) // are we the first down leaf for the upper leaf?
+  //      Up->DownLeaf = this;
+  //  UpLeaf = Up;
+  //  DownLeaf = NULL;
+  if (previous != NULL) {
+    MoleculeLeafClass *Walker = previous->next;
+    previous->next = this;
+    next = Walker;
+  } else {
+    next = NULL;
+  }
+};
+
+/** Destructor for MoleculeLeafClass.
+ */
+MoleculeLeafClass::~MoleculeLeafClass()
+{
+  //  if (DownLeaf != NULL) {// drop leaves further down
+  //    MoleculeLeafClass *Walker = DownLeaf;
+  //    MoleculeLeafClass *Next;
+  //    do {
+  //      Next = Walker->NextLeaf;
+  //      delete(Walker);
+  //      Walker = Next;
+  //    } while (Walker != NULL);
+  //    // Last Walker sets DownLeaf automatically to NULL
+  //  }
+  // remove the leaf itself
+  if (Leaf != NULL) {
+    Leaf->removeAtomsinMolecule();
+    World::getInstance().destroyMolecule(Leaf);
+    Leaf = NULL;
+  }
+  // remove this Leaf from level list
+  if (previous != NULL)
+    previous->next = next;
+  //  } else { // we are first in list (connects to UpLeaf->DownLeaf)
+  //    if ((NextLeaf != NULL) && (NextLeaf->UpLeaf == NULL))
+  //      NextLeaf->UpLeaf = UpLeaf;  // either null as we are top level or the upleaf of the first node
+  //    if (UpLeaf != NULL)
+  //      UpLeaf->DownLeaf = NextLeaf;  // either null as we are only leaf or NextLeaf if we are just the first
+  //  }
+  //  UpLeaf = NULL;
+  if (next != NULL) // are we last in list
+    next->previous = previous;
+  next = NULL;
+  previous = NULL;
+};
+
+/** Adds \a molecule leaf to the tree.
+ * \param *ptr ptr to molecule to be added
+ * \param *Previous previous MoleculeLeafClass referencing level and which on the level
+ * \return true - success, false - something went wrong
+ */
+bool MoleculeLeafClass::AddLeaf(molecule *ptr, MoleculeLeafClass *Previous)
+{
+  return false;
+};
+
+/** Fills the root stack for sites to be used as root in fragmentation depending on order or adaptivity criteria
+ * Again, as in \sa FillBondStructureFromReference steps recursively through each Leaf in this chain list of molecule's.
+ * \param *out output stream for debugging
+ * \param *&RootStack stack to be filled
+ * \param *AtomMask defines true/false per global Atom::Nr to mask in/out each nuclear site
+ * \param &FragmentCounter counts through the fragments in this MoleculeLeafClass
+ * \return true - stack is non-empty, fragmentation necessary, false - stack is empty, no more sites to update
+ */
+bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
+{
+  atom *Father = NULL;
+
+  if (RootStack != NULL) {
+    // find first root candidates
+    if (&(RootStack[FragmentCounter]) != NULL) {
+      RootStack[FragmentCounter].clear();
+      for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
+        Father = (*iter)->GetTrueFather();
+        if (AtomMask[Father->getNr()]) // apply mask
+#ifdef ADDHYDROGEN
+          if ((*iter)->getType()->getAtomicNumber() != 1) // skip hydrogen
+#endif
+          RootStack[FragmentCounter].push_front((*iter)->getNr());
+      }
+      if (next != NULL)
+        next->FillRootStackForSubgraphs(RootStack, AtomMask, ++FragmentCounter);
+    } else {
+      DoLog(1) && (Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl);
+      return false;
+    }
+    FragmentCounter--;
+    return true;
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "Rootstack is NULL." << endl);
+    return false;
+  }
+};
+
+/** The indices per keyset are compared to the respective father's Atom::Nr in each subgraph and thus put into \a **&FragmentList.
+ * \param *out output stream fro debugging
+ * \param *reference reference molecule with the bond structure to be copied
+ * \param *KeySetList list with all keysets
+ * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
+ * \param **&FragmentList list to be allocated and returned
+ * \param &FragmentCounter counts the fragments as we move along the list
+ * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
+ * \retuen true - success, false - failure
+ */
+bool MoleculeLeafClass::AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList)
+{
+  bool status = true;
+  int KeySetCounter = 0;
+
+  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
+  // fill ListOfLocalAtoms if NULL was given
+  if (!Leaf->FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount())) {
+    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
+    return false;
+  }
+
+  // allocate fragment list
+  if (FragmentList == NULL) {
+    KeySetCounter = Count();
+    FragmentList = new Graph*[KeySetCounter];
+    for (int i=0;i<KeySetCounter;i++)
+      FragmentList[i] = NULL;
+    KeySetCounter = 0;
+  }
+
+  if ((KeySetList != NULL) && (KeySetList->size() != 0)) { // if there are some scanned keysets at all
+    // assign scanned keysets
+    if (FragmentList[FragmentCounter] == NULL)
+      FragmentList[FragmentCounter] = new Graph;
+    KeySet *TempSet = new KeySet;
+    for (Graph::iterator runner = KeySetList->begin(); runner != KeySetList->end(); runner++) { // key sets contain global numbers!
+      if (ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*((*runner).first.begin()))->getNr()] != NULL) {// as we may assume that that bond structure is unchanged, we only test the first key in each set
+        // translate keyset to local numbers
+        for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
+          TempSet->insert(ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*sprinter)->getNr()]->getNr());
+        // insert into FragmentList
+        FragmentList[FragmentCounter]->insert(GraphPair(*TempSet, pair<int, double> (KeySetCounter++, (*runner).second.second)));
+      }
+      TempSet->clear();
+    }
+    delete (TempSet);
+    if (KeySetCounter == 0) {// if there are no keysets, delete the list
+      DoLog(1) && (Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl);
+      delete (FragmentList[FragmentCounter]);
+    } else
+      DoLog(1) && (Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl);
+    FragmentCounter++;
+    if (next != NULL)
+      next->AssignKeySetsToFragment(reference, KeySetList, ListOfLocalAtoms, FragmentList, FragmentCounter, FreeList);
+    FragmentCounter--;
+  } else
+    DoLog(1) && (Log() << Verbose(1) << "KeySetList is NULL or empty." << endl);
+
+  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
+    // free the index lookup list
+    delete[](ListOfLocalAtoms[FragmentCounter]);
+  }
+  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
+  return status;
+};
+
+/** Translate list into global numbers (i.e. ones that are valid in "this" molecule, not in MolecularWalker->Leaf)
+ * \param *out output stream for debugging
+ * \param **FragmentList Graph with local numbers per fragment
+ * \param &FragmentCounter counts the fragments as we move along the list
+ * \param &TotalNumberOfKeySets global key set counter
+ * \param &TotalGraph Graph to be filled with global numbers
+ */
+void MoleculeLeafClass::TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph)
+{
+  DoLog(1) && (Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl);
+  KeySet *TempSet = new KeySet;
+  if (FragmentList[FragmentCounter] != NULL) {
+    for (Graph::iterator runner = FragmentList[FragmentCounter]->begin(); runner != FragmentList[FragmentCounter]->end(); runner++) {
+      for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
+        TempSet->insert((Leaf->FindAtom(*sprinter))->GetTrueFather()->getNr());
+      TotalGraph.insert(GraphPair(*TempSet, pair<int, double> (TotalNumberOfKeySets++, (*runner).second.second)));
+      TempSet->clear();
+    }
+    delete (TempSet);
+  } else {
+    DoLog(1) && (Log() << Verbose(1) << "FragmentList is NULL." << endl);
+  }
+  if (next != NULL)
+    next->TranslateIndicesToGlobalIDs(FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph);
+  FragmentCounter--;
+  DoLog(1) && (Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl);
+};
+
+/** Simply counts the number of items in the list, from given MoleculeLeafClass.
+ * \return number of items
+ */
+int MoleculeLeafClass::Count() const
+{
+  if (next != NULL)
+    return next->Count() + 1;
+  else
+    return 1;
+};
+
Index: src/MoleculeLeafClass.hpp
===================================================================
--- src/MoleculeLeafClass.hpp	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
+++ src/MoleculeLeafClass.hpp	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
@@ -0,0 +1,46 @@
+/*
+ * MoleculeLeafClass.hpp
+ *
+ *  Created on: Oct 20, 2011
+ *      Author: heber
+ */
+
+#ifndef MOLECULELEAFCLASS_HPP_
+#define MOLECULELEAFCLASS_HPP_
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Fragmentation/fragmentation_helpers.hpp"
+
+class atom;
+class Graph;
+class molecule;
+
+
+/** A leaf for a tree of \a molecule class
+ * Wraps molecules in a tree structure
+ */
+class MoleculeLeafClass
+{
+public:
+  molecule *Leaf; //!< molecule of this leaf
+  //MoleculeLeafClass *UpLeaf;        //!< Leaf one level up
+  //MoleculeLeafClass *DownLeaf;      //!< First leaf one level down
+  MoleculeLeafClass *previous; //!< Previous leaf on this level
+  MoleculeLeafClass *next; //!< Next leaf on this level
+
+  //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous);
+  MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf);
+  ~MoleculeLeafClass();
+
+  bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
+  bool FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter);
+  bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);
+  void TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph);
+  int Count() const;
+};
+
+
+#endif /* MOLECULELEAFCLASS_HPP_ */
Index: src/molecule.hpp
===================================================================
--- src/molecule.hpp	(revision ba94c53b55b13c65d4a227ddc75d8d7e657d9670)
+++ src/molecule.hpp	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
@@ -27,5 +27,4 @@
 #include "CodePatterns/ObservedIterator.hpp"
 #include "CodePatterns/Cacheable.hpp"
-#include "Fragmentation/fragmentation_helpers.hpp"
 #include "Helpers/defs.hpp"
 #include "Formula.hpp"
@@ -275,26 +274,4 @@
 };
 
-/** A leaf for a tree of \a molecule class
- * Wraps molecules in a tree structure
- */
-class MoleculeLeafClass
-{
-public:
-  molecule *Leaf; //!< molecule of this leaf
-  //MoleculeLeafClass *UpLeaf;        //!< Leaf one level up
-  //MoleculeLeafClass *DownLeaf;      //!< First leaf one level down
-  MoleculeLeafClass *previous; //!< Previous leaf on this level
-  MoleculeLeafClass *next; //!< Next leaf on this level
-
-  //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous);
-  MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf);
-  ~MoleculeLeafClass();
-
-  bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
-  bool FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter);
-  bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);
-  void TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph);
-  int Count() const;
-};
 
 #endif /*MOLECULES_HPP_*/
Index: src/moleculelist.cpp
===================================================================
--- src/moleculelist.cpp	(revision ba94c53b55b13c65d4a227ddc75d8d7e657d9670)
+++ src/moleculelist.cpp	(revision d3abb155bcc85709402bb9d4f61ee6386c074874)
@@ -19,18 +19,19 @@
 #include "CodePatterns/MemDebug.hpp"
 
-#include <cstring>
-
-#include <gsl/gsl_inline.h>
+//#include <cstring>
+
+//#include <gsl/gsl_inline.h>
 #include <gsl/gsl_heapsort.h>
+
+#include "molecule.hpp"
+
+#include "CodePatterns/Log.hpp"
 
 #include "atom.hpp"
 #include "Bond/bond.hpp"
-#include "Tesselation/boundary.hpp"
 #include "Box.hpp"
-#include "CodePatterns/Assert.hpp"
-#include "CodePatterns/Log.hpp"
-#include "CodePatterns/Verbose.hpp"
 #include "config.hpp"
 #include "Element/element.hpp"
+#include "Element/periodentafel.hpp"
 #include "Fragmentation/Graph.hpp"
 #include "Fragmentation/KeySet.hpp"
@@ -38,14 +39,7 @@
 #include "Helpers/helpers.hpp"
 #include "LinearAlgebra/RealSpaceMatrix.hpp"
-#include "linkedcell.hpp"
-#include "molecule.hpp"
-#include "Parser/MpqcParser.hpp"
 #include "Parser/FormatParserStorage.hpp"
-#include "Element/periodentafel.hpp"
-#include "Tesselation/tesselation.hpp"
 #include "World.hpp"
-#include "WorldTime.hpp"
-
-/*********************************** Functions for class MoleculeListClass *************************/
+
 
 /** Constructor for MoleculeListClass.
@@ -755,219 +749,2 @@
     }
 };
-
-
-/******************************************* Class MoleculeLeafClass ************************************************/
-
-/** Constructor for MoleculeLeafClass root leaf.
- * \param *Up Leaf on upper level
- * \param *PreviousLeaf NULL - We are the first leaf on this level, otherwise points to previous in list
- */
-//MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *Up = NULL, MoleculeLeafClass *Previous = NULL)
-MoleculeLeafClass::MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf = NULL) :
-  Leaf(NULL),
-  previous(PreviousLeaf)
-{
-  //  if (Up != NULL)
-  //    if (Up->DownLeaf == NULL) // are we the first down leaf for the upper leaf?
-  //      Up->DownLeaf = this;
-  //  UpLeaf = Up;
-  //  DownLeaf = NULL;
-  if (previous != NULL) {
-    MoleculeLeafClass *Walker = previous->next;
-    previous->next = this;
-    next = Walker;
-  } else {
-    next = NULL;
-  }
-};
-
-/** Destructor for MoleculeLeafClass.
- */
-MoleculeLeafClass::~MoleculeLeafClass()
-{
-  //  if (DownLeaf != NULL) {// drop leaves further down
-  //    MoleculeLeafClass *Walker = DownLeaf;
-  //    MoleculeLeafClass *Next;
-  //    do {
-  //      Next = Walker->NextLeaf;
-  //      delete(Walker);
-  //      Walker = Next;
-  //    } while (Walker != NULL);
-  //    // Last Walker sets DownLeaf automatically to NULL
-  //  }
-  // remove the leaf itself
-  if (Leaf != NULL) {
-    Leaf->removeAtomsinMolecule();
-    World::getInstance().destroyMolecule(Leaf);
-    Leaf = NULL;
-  }
-  // remove this Leaf from level list
-  if (previous != NULL)
-    previous->next = next;
-  //  } else { // we are first in list (connects to UpLeaf->DownLeaf)
-  //    if ((NextLeaf != NULL) && (NextLeaf->UpLeaf == NULL))
-  //      NextLeaf->UpLeaf = UpLeaf;  // either null as we are top level or the upleaf of the first node
-  //    if (UpLeaf != NULL)
-  //      UpLeaf->DownLeaf = NextLeaf;  // either null as we are only leaf or NextLeaf if we are just the first
-  //  }
-  //  UpLeaf = NULL;
-  if (next != NULL) // are we last in list
-    next->previous = previous;
-  next = NULL;
-  previous = NULL;
-};
-
-/** Adds \a molecule leaf to the tree.
- * \param *ptr ptr to molecule to be added
- * \param *Previous previous MoleculeLeafClass referencing level and which on the level
- * \return true - success, false - something went wrong
- */
-bool MoleculeLeafClass::AddLeaf(molecule *ptr, MoleculeLeafClass *Previous)
-{
-  return false;
-};
-
-/** Fills the root stack for sites to be used as root in fragmentation depending on order or adaptivity criteria
- * Again, as in \sa FillBondStructureFromReference steps recursively through each Leaf in this chain list of molecule's.
- * \param *out output stream for debugging
- * \param *&RootStack stack to be filled
- * \param *AtomMask defines true/false per global Atom::Nr to mask in/out each nuclear site
- * \param &FragmentCounter counts through the fragments in this MoleculeLeafClass
- * \return true - stack is non-empty, fragmentation necessary, false - stack is empty, no more sites to update
- */
-bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
-{
-  atom *Father = NULL;
-
-  if (RootStack != NULL) {
-    // find first root candidates
-    if (&(RootStack[FragmentCounter]) != NULL) {
-      RootStack[FragmentCounter].clear();
-      for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
-        Father = (*iter)->GetTrueFather();
-        if (AtomMask[Father->getNr()]) // apply mask
-#ifdef ADDHYDROGEN
-          if ((*iter)->getType()->getAtomicNumber() != 1) // skip hydrogen
-#endif
-          RootStack[FragmentCounter].push_front((*iter)->getNr());
-      }
-      if (next != NULL)
-        next->FillRootStackForSubgraphs(RootStack, AtomMask, ++FragmentCounter);
-    } else {
-      DoLog(1) && (Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl);
-      return false;
-    }
-    FragmentCounter--;
-    return true;
-  } else {
-    DoLog(1) && (Log() << Verbose(1) << "Rootstack is NULL." << endl);
-    return false;
-  }
-};
-
-/** The indices per keyset are compared to the respective father's Atom::Nr in each subgraph and thus put into \a **&FragmentList.
- * \param *out output stream fro debugging
- * \param *reference reference molecule with the bond structure to be copied
- * \param *KeySetList list with all keysets
- * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in global molecule, may be NULL on start, then it is filled
- * \param **&FragmentList list to be allocated and returned
- * \param &FragmentCounter counts the fragments as we move along the list
- * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
- * \retuen true - success, false - failure
- */
-bool MoleculeLeafClass::AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList)
-{
-  bool status = true;
-  int KeySetCounter = 0;
-
-  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
-  // fill ListOfLocalAtoms if NULL was given
-  if (!Leaf->FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount())) {
-    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
-    return false;
-  }
-
-  // allocate fragment list
-  if (FragmentList == NULL) {
-    KeySetCounter = Count();
-    FragmentList = new Graph*[KeySetCounter];
-    for (int i=0;i<KeySetCounter;i++)
-      FragmentList[i] = NULL;
-    KeySetCounter = 0;
-  }
-
-  if ((KeySetList != NULL) && (KeySetList->size() != 0)) { // if there are some scanned keysets at all
-    // assign scanned keysets
-    if (FragmentList[FragmentCounter] == NULL)
-      FragmentList[FragmentCounter] = new Graph;
-    KeySet *TempSet = new KeySet;
-    for (Graph::iterator runner = KeySetList->begin(); runner != KeySetList->end(); runner++) { // key sets contain global numbers!
-      if (ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*((*runner).first.begin()))->getNr()] != NULL) {// as we may assume that that bond structure is unchanged, we only test the first key in each set
-        // translate keyset to local numbers
-        for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
-          TempSet->insert(ListOfLocalAtoms[FragmentCounter][reference->FindAtom(*sprinter)->getNr()]->getNr());
-        // insert into FragmentList
-        FragmentList[FragmentCounter]->insert(GraphPair(*TempSet, pair<int, double> (KeySetCounter++, (*runner).second.second)));
-      }
-      TempSet->clear();
-    }
-    delete (TempSet);
-    if (KeySetCounter == 0) {// if there are no keysets, delete the list
-      DoLog(1) && (Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl);
-      delete (FragmentList[FragmentCounter]);
-    } else
-      DoLog(1) && (Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl);
-    FragmentCounter++;
-    if (next != NULL)
-      next->AssignKeySetsToFragment(reference, KeySetList, ListOfLocalAtoms, FragmentList, FragmentCounter, FreeList);
-    FragmentCounter--;
-  } else
-    DoLog(1) && (Log() << Verbose(1) << "KeySetList is NULL or empty." << endl);
-
-  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
-    // free the index lookup list
-    delete[](ListOfLocalAtoms[FragmentCounter]);
-  }
-  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
-  return status;
-};
-
-/** Translate list into global numbers (i.e. ones that are valid in "this" molecule, not in MolecularWalker->Leaf)
- * \param *out output stream for debugging
- * \param **FragmentList Graph with local numbers per fragment
- * \param &FragmentCounter counts the fragments as we move along the list
- * \param &TotalNumberOfKeySets global key set counter
- * \param &TotalGraph Graph to be filled with global numbers
- */
-void MoleculeLeafClass::TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph)
-{
-  DoLog(1) && (Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl);
-  KeySet *TempSet = new KeySet;
-  if (FragmentList[FragmentCounter] != NULL) {
-    for (Graph::iterator runner = FragmentList[FragmentCounter]->begin(); runner != FragmentList[FragmentCounter]->end(); runner++) {
-      for (KeySet::iterator sprinter = (*runner).first.begin(); sprinter != (*runner).first.end(); sprinter++)
-        TempSet->insert((Leaf->FindAtom(*sprinter))->GetTrueFather()->getNr());
-      TotalGraph.insert(GraphPair(*TempSet, pair<int, double> (TotalNumberOfKeySets++, (*runner).second.second)));
-      TempSet->clear();
-    }
-    delete (TempSet);
-  } else {
-    DoLog(1) && (Log() << Verbose(1) << "FragmentList is NULL." << endl);
-  }
-  if (next != NULL)
-    next->TranslateIndicesToGlobalIDs(FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph);
-  FragmentCounter--;
-  DoLog(1) && (Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl);
-};
-
-/** Simply counts the number of items in the list, from given MoleculeLeafClass.
- * \return number of items
- */
-int MoleculeLeafClass::Count() const
-{
-  if (next != NULL)
-    return next->Count() + 1;
-  else
-    return 1;
-};
-
