Index: src/moleculelist.cpp
===================================================================
--- src/moleculelist.cpp	(revision 35b6985cb4b968c855916ec0ced6e74b690ac7b1)
+++ src/moleculelist.cpp	(revision c27778c8cf9d03d323711246738e105de9b3c9d4)
@@ -1017,10 +1017,9 @@
  * \param *out output stream for debugging
  * \param *reference reference molecule with the bond structure to be copied
- * \param &FragmentCounter Counter needed to address \a **ListOfLocalAtoms
- * \param ***ListOfLocalAtoms Lookup table for each subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
+ * \param **&ListOfLocalAtoms Lookup table for this subgraph and index of each atom in \a *reference, may be NULL on start, then it is filled
  * \param FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
  * \return true - success, false - faoilure
  */
-bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
+bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList)
 {
   atom *OtherWalker = NULL;
@@ -1031,5 +1030,5 @@
   DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
   // fill ListOfLocalAtoms if NULL was given
-  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
+  if (!FillListOfLocalAtoms(ListOfLocalAtoms, reference->getAtomCount(), FreeList)) {
     DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
     return false;
@@ -1048,10 +1047,10 @@
       AtomNo = Father->nr; // global id of the current walker
       for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) {
-        OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
+        OtherWalker = ListOfLocalAtoms[(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
         if (OtherWalker != NULL) {
           if (OtherWalker->nr > (*iter)->nr)
             Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree);
         } else {
-          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
+          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
           status = false;
         }
@@ -1062,7 +1061,5 @@
   if ((FreeList) && (ListOfLocalAtoms != NULL)) {
     // free the index lookup list
-    delete[](ListOfLocalAtoms[FragmentCounter]);
-    if (FragmentCounter == 0) // first fragments frees the initial pointer to list
-      delete[](ListOfLocalAtoms);
+    delete[](ListOfLocalAtoms);
   }
   DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl);
@@ -1110,31 +1107,18 @@
 /** Fills a lookup list of father's Atom::nr -> atom for each subgraph.
  * \param *out output stream from debugging
- * \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 FragmentCounter counts the fragments as we move along the list
+ * \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 GlobalAtomCount number of atoms in the complete molecule
  * \param &FreeList true - ***ListOfLocalAtoms is free'd before return, false - it is not
- * \return true - success, false - failure
- */
-bool MoleculeLeafClass::FillListOfLocalAtoms(atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList)
+ * \return true - success, false - failure (ListOfLocalAtoms != NULL)
+ */
+bool MoleculeLeafClass::FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount, bool &FreeList)
 {
   bool status = true;
 
-  if (ListOfLocalAtoms == NULL) { // allocated initial pointer
-    // allocate and set each field to NULL
-    const int Counter = Count();
-    ASSERT(FragmentCounter < Counter, "FillListOfLocalAtoms: FragmenCounter greater than present fragments.");
-    ListOfLocalAtoms = new atom**[Counter];
-    if (ListOfLocalAtoms == NULL) {
-      FreeList = FreeList && false;
-      status = false;
-    }
-    for (int i=0;i<Counter;i++)
-      ListOfLocalAtoms[i] = NULL;
-  }
-
-  if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph
-    status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
+  if (ListOfLocalAtoms == NULL) { // allocate and fill list of this fragment/subgraph
+    status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms, GlobalAtomCount);
     FreeList = FreeList && true;
-  }
+  } else
+    return false;
 
   return status;
@@ -1158,5 +1142,5 @@
   DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
   // fill ListOfLocalAtoms if NULL was given
-  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
+  if (!FillListOfLocalAtoms(ListOfLocalAtoms[FragmentCounter], reference->getAtomCount(), FreeList)) {
     DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
     return false;
@@ -1203,6 +1187,4 @@
     // free the index lookup list
     delete[](ListOfLocalAtoms[FragmentCounter]);
-    if (FragmentCounter == 0) // first fragments frees the initial pointer to list
-      delete[](ListOfLocalAtoms);
   }
   DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
