Index: src/molecules.cpp
===================================================================
--- src/molecules.cpp	(revision af6d8f00912cd5022f1a2c33ac397ac378ec965d)
+++ src/molecules.cpp	(revision 4aa03a552cf306f8b3265e786d08e545bf01bed4)
@@ -2523,10 +2523,10 @@
         No = (*runner).second.first;
         Walker = FindAtom(No);
-        if (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]) {
+        //if (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]) {
           *out << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl; 
           AtomMask[No] = true;
           status = true;
-        } else
-          *out << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", however MinimumRingSize of " << MinimumRingSize[Walker->nr] << " does not allow further adaptive increase." << endl; 
+        //} else
+          //*out << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", however MinimumRingSize of " << MinimumRingSize[Walker->nr] << " does not allow further adaptive increase." << endl; 
       }
       // close and done
@@ -2556,10 +2556,10 @@
       {
         AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
-        if ((Order != 0) && (Walker->AdaptiveOrder < Order) && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))
+        if ((Order != 0) && (Walker->AdaptiveOrder < Order)) // && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))
           status = true;
       }
     }
     if ((Order == 0) && (AtomMask[AtomCount] == true))  // single stepping, just check
-      status = false;
+      status = true;
       
     if (!status)
@@ -3152,4 +3152,6 @@
   atom **SonList = (atom **) Malloc(sizeof(atom *)*AtomCount, "molecule::StoreFragmentFromStack: **SonList");
   molecule *Leaf = new molecule(elemente);
+  bool LonelyFlag = false;
+  int size;
   
 //  *out << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl;
@@ -3164,7 +3166,9 @@
 
   // first create the minimal set of atoms from the KeySet
+  size = 0;
   for(KeySet::iterator runner = Leaflet.begin(); runner != Leaflet.end(); runner++) {
     FatherOfRunner = FindAtom((*runner));  // find the id
     SonList[FatherOfRunner->nr] = Leaf->AddCopyAtom(FatherOfRunner);
+    size++;
   }
   
@@ -3174,4 +3178,5 @@
   while (Runner->next != Leaf->end) {
     Runner = Runner->next;
+    LonelyFlag = true;
     FatherOfRunner = Runner->father;
     if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
@@ -3191,4 +3196,5 @@
 //            *out << Verbose(3) << "Not adding bond, labels in wrong order." << endl;
           }
+          LonelyFlag = false;
         } else {
 //          *out << ", who has no son in this fragment molecule." << endl; 
@@ -3202,4 +3208,7 @@
     } else {
       *out << Verbose(0) << "ERROR: Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl;
+    }
+    if ((LonelyFlag) && (size > 1)) {
+      *out << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl;
     }
 #ifdef ADDHYDROGEN
@@ -3468,9 +3477,11 @@
   int NumCombinations;
   bool bit;
-  int bits, TouchedIndex, SubSetDimension, SP;
+  int bits, TouchedIndex, SubSetDimension, SP, Added;
   int Removal;
+  int SpaceLeft;
   int *TouchedList = (int *) Malloc(sizeof(int)*(SubOrder+1), "molecule::SPFragmentGenerator: *TouchedList");
   bond *Binder = NULL;
   bond **BondsList = NULL;
+  KeySetTestPair TestKeySetInsert;
 
   NumCombinations = 1 << SetDimension;
@@ -3500,4 +3511,5 @@
     if (bits <= SubOrder) { // if not greater than additional atoms allowed on stack, continue
       // --1-- add this set of the power set of bond partners to the snake stack
+      Added = 0;
       for (int j=0;j<SetDimension;j++) {  // pull out every bit by shifting
         bit = ((i & (1 << j)) != 0);  // mask the bit for the j-th bond
@@ -3508,6 +3520,11 @@
             //*out << Verbose(2+verbosity) << "Not used so far, label " << FragmentSearch->Labels[OtherWalker->nr] << " is bigger than Root's " << FragmentSearch->Labels[FragmentSearch->Root->nr] << "." << endl;
           *out << Verbose(2+verbosity) << "Adding " << *OtherWalker << " with nr " << OtherWalker->nr << "." << endl;
-          TouchedList[TouchedIndex++] = OtherWalker->nr;  // note as added
-          FragmentSearch->FragmentSet->insert(OtherWalker->nr);
+          TestKeySetInsert = FragmentSearch->FragmentSet->insert(OtherWalker->nr); 
+          if (TestKeySetInsert.second) {
+            TouchedList[TouchedIndex++] = OtherWalker->nr;  // note as added
+            Added++;
+          } else {
+            *out << Verbose(2+verbosity) << "This was item was already present in the keyset." << endl;
+          }
             //FragmentSearch->UsedList[OtherWalker->nr][i] = true;
           //}
@@ -3517,32 +3534,35 @@
       }
       
-      if (bits < SubOrder) {
-        *out << Verbose(1+verbosity) << "There's still some space left on stack: " << (SubOrder - bits) << "." << endl;
-        // --2-- look at all added end pieces of this combination, construct bond subsets and sweep through a power set of these by recursion
-        SP = RootDistance+1;	// this is the next level
-        // first count the members in the subset
-        SubSetDimension = 0;
-        Binder = FragmentSearch->BondsPerSPList[2*SP];		// start node for this level
-        while (Binder->next != FragmentSearch->BondsPerSPList[2*SP+1]) {		// compare to end node of this level
-          Binder = Binder->next;
-          for (int k=TouchedIndex;k--;) {
-            if (Binder->Contains(TouchedList[k]))   // if we added this very endpiece
-              SubSetDimension++;
+      SpaceLeft = SubOrder - Added ;// SubOrder - bits; // due to item's maybe being already present, this does not work anymore 
+      if (SpaceLeft > 0) {
+        *out << Verbose(1+verbosity) << "There's still some space left on stack: " << SpaceLeft << "." << endl;
+        if (SubOrder > 1) {    // Due to Added above we have to check extra whether we're not already reaching beyond the desired Order
+          // --2-- look at all added end pieces of this combination, construct bond subsets and sweep through a power set of these by recursion
+          SP = RootDistance+1;	// this is the next level
+          // first count the members in the subset
+          SubSetDimension = 0;
+          Binder = FragmentSearch->BondsPerSPList[2*SP];		// start node for this level
+          while (Binder->next != FragmentSearch->BondsPerSPList[2*SP+1]) {		// compare to end node of this level
+            Binder = Binder->next;
+            for (int k=TouchedIndex;k--;) {
+              if (Binder->Contains(TouchedList[k]))   // if we added this very endpiece
+                SubSetDimension++;
+            }
           }
+          // then allocate and fill the list
+          BondsList = (bond **) Malloc(sizeof(bond *)*SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");
+          SubSetDimension = 0;
+          Binder = FragmentSearch->BondsPerSPList[2*SP];
+          while (Binder->next != FragmentSearch->BondsPerSPList[2*SP+1]) {
+            Binder = Binder->next;
+            for (int k=0;k<TouchedIndex;k++) {
+              if (Binder->leftatom->nr == TouchedList[k])   // leftatom is always the close one
+                BondsList[SubSetDimension++] = Binder;
+            }
+          }
+          *out << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl;
+          SPFragmentGenerator(out, FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits);  
+          Free((void **)&BondsList, "molecule::SPFragmentGenerator: **BondsList");
         }
-        // then allocate and fill the list
-        BondsList = (bond **) Malloc(sizeof(bond *)*SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");
-        SubSetDimension = 0;
-        Binder = FragmentSearch->BondsPerSPList[2*SP];
-        while (Binder->next != FragmentSearch->BondsPerSPList[2*SP+1]) {
-          Binder = Binder->next;
-          for (int k=0;k<TouchedIndex;k++) {
-            if (Binder->leftatom->nr == TouchedList[k])   // leftatom is always the close one
-              BondsList[SubSetDimension++] = Binder;
-          }
-        }
-        *out << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl;
-        SPFragmentGenerator(out, FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits);  
-        Free((void **)&BondsList, "molecule::SPFragmentGenerator: **BondsList");
       } else {
         // --2-- otherwise store the complete fragment
@@ -3552,4 +3572,7 @@
         for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++)
           *out << (*runner) << " "; 
+        *out << endl;
+        if (!CheckForConnectedSubgraph(out, FragmentSearch->FragmentSet))
+          *out << Verbose(0) << "ERROR: The found fragment is not a connected subgraph!" << endl;
         InsertFragmentIntoGraph(out, FragmentSearch);
         //Removal = LookForRemovalCandidate(out, FragmentSearch->FragmentSet, FragmentSearch->ShortestPathList);
@@ -3577,4 +3600,54 @@
   *out << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl;
 };
+
+/** For a given keyset \a *Fragment, checks whether it is connected in the current molecule.
+ * \param *out output stream for debugging
+ * \param *Fragment Keyset of fragment's vertices
+ * \return true - connected, false - disconnected
+ * \note this is O(n^2) for it's just a bug checker not meant for permanent use!
+ */ 
+bool molecule::CheckForConnectedSubgraph(ofstream *out, KeySet *Fragment)
+{
+  atom *Walker = NULL, *Walker2 = NULL;
+  bool BondStatus = false;
+  int size;
+  
+  *out << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl;
+  *out << Verbose(2) << "Disconnected atom: ";
+  
+  // count number of atoms in graph
+  size = 0;
+  for(KeySet::iterator runner = Fragment->begin(); runner != Fragment->end(); runner++)
+    size++;
+  if (size > 1)
+    for(KeySet::iterator runner = Fragment->begin(); runner != Fragment->end(); runner++) {
+      Walker = FindAtom(*runner);
+      BondStatus = false;
+      for(KeySet::iterator runners = Fragment->begin(); runners != Fragment->end(); runners++) {
+        Walker2 = FindAtom(*runners);
+        for (int i=0;i<NumberOfBondsPerAtom[Walker->nr]; i++) {
+          if (ListOfBondsPerAtom[Walker->nr][i]->GetOtherAtom(Walker) == Walker2) {
+            BondStatus = true;
+            break;
+          }
+          if (BondStatus)
+            break;
+        }
+      }
+      if (!BondStatus) {
+        *out << (*Walker) << endl;
+        return false;
+      }
+    }
+  else {
+    *out << "none." << endl;
+    return true;
+  }
+  *out << "none." << endl;
+
+  *out << Verbose(1) << "End of CheckForConnectedSubgraph" << endl;
+
+  return true;
+}
 
 /** Creates a list of all unique fragments of certain vertex size from a given graph \a Fragment for a given root vertex in the context of \a this molecule.
@@ -3596,114 +3669,90 @@
 {
   int SP, UniqueIndex, AtomKeyNr;
-  int *NumberOfAtomsSPLevel = (int *) Malloc(sizeof(int)*Order, "molecule::PowerSetGenerator: *SPLevelCount");
-  atom *Walker = NULL, *OtherWalker = NULL;
+  atom *Walker = NULL, *OtherWalker = NULL, *Predecessor = NULL;
   bond *Binder = NULL;
+  bond *CurrentEdge = NULL;
   bond **BondsList = NULL;
-  KeyStack AtomStack;
-  atom **PredecessorList = (atom **) Malloc(sizeof(atom *)*AtomCount, "molecule::PowerSetGenerator: **PredecessorList");
   int RootKeyNr = FragmentSearch.Root->nr;
   int Counter = FragmentSearch.FragmentCounter;
-
-  for (int i=AtomCount;i--;) {
-    PredecessorList[i] = NULL;
-  }
+  int RemainingWalkers;
 
   *out << endl;
   *out << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl;
 
+  // prepare Label and SP arrays of the BFS search
   UniqueIndex = 0;
   if (FragmentSearch.Labels[RootKeyNr] == -1)
     FragmentSearch.Labels[RootKeyNr] = UniqueIndex++;
   FragmentSearch.ShortestPathList[RootKeyNr] = 0;
-  // prepare the atom stack counters (number of atoms with certain SP on stack)
-  for (int i=Order;i--;)
-    NumberOfAtomsSPLevel[i] = 0;
-  NumberOfAtomsSPLevel[0] = 1;  // for root
-  SP = -1;
+
+  // prepare root level (SP = 0) and a loop bond denoting Root
+  for (int i=1;i<Order;i++)
+    FragmentSearch.BondsPerSPCount[i] = 0;
+  FragmentSearch.BondsPerSPCount[0] = 1;
+  Binder = new bond(FragmentSearch.Root, FragmentSearch.Root); 
+  add(Binder, FragmentSearch.BondsPerSPList[1]);
+  
+  // do a BFS search to fill the SP lists and label the found vertices
+  // Actually, we should construct a spanning tree vom the root atom and select all edges therefrom and put them into
+  // according shortest path lists. However, we don't. Rather we fill these lists right away, as they do form a spanning
+  // tree already sorted into various SP levels. That's why we just do loops over the depth (CurrentSP) and breadth
+  // (EdgeinSPLevel) of this tree ... 
+  // In another picture, the bonds always contain a direction by rightatom being the one more distant from root and hence
+  // naturally leftatom forming its predecessor, preventing the BFS"seeker" from continuing in the wrong direction.
   *out << endl;
   *out << Verbose(0) << "Starting BFS analysis ..." << endl;
-  // push as first on atom stack and goooo ...
-  AtomStack.clear();  
-  AtomStack.push_back(RootKeyNr);
-  *out << Verbose(0) << "Cleared AtomStack and pushed root as first item onto it." << endl;
-  // do a BFS search to fill the SP lists and label the found vertices
-  while (!AtomStack.empty()) {
-    // pop next atom
-    AtomKeyNr = AtomStack.front();
-    AtomStack.pop_front();
-    if (SP != -1)
-      NumberOfAtomsSPLevel[SP]--;
-    if ((SP == -1) || (NumberOfAtomsSPLevel[SP] == -1)) {
-      SP++;
-      NumberOfAtomsSPLevel[SP]--; // carry over "-1" to next level
-      *out << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with 0 item(s)";
-      if (SP > 0)
-        *out << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl;
-      else
-        *out << "." << endl;
+  for (SP = 0; SP < (Order-1); SP++) {
+    *out << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)";
+    if (SP > 0) {
+      *out << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl;
       FragmentSearch.BondsPerSPCount[SP] = 0;
-    } else {
-      *out << Verbose(1) << "Still " << NumberOfAtomsSPLevel[SP]+1 << " on this SP (" << SP << ") level, currently having " << FragmentSearch.BondsPerSPCount[SP] << " item(s)." << endl;
-    }
-    Walker = FindAtom(AtomKeyNr);
-    *out << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and label " << FragmentSearch.Labels[AtomKeyNr] << " and SP of " << SP << "." << endl;
-    // check for new sp level
-    // go through all its bonds
-    *out << Verbose(1) << "Going through all bonds of Walker." << endl;
-    for (int i=0;i<NumberOfBondsPerAtom[AtomKeyNr];i++) {
-      Binder = ListOfBondsPerAtom[AtomKeyNr][i];
-      OtherWalker = Binder->GetOtherAtom(Walker);
-      if ((RestrictedKeySet.find(OtherWalker->nr) != RestrictedKeySet.end())
-#ifdef ADDHYDROGEN
-       && (OtherWalker->type->Z != 1)
-#endif
-                                                            ) {  // skip hydrogens and restrict to fragment
-        *out << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *Binder << "." << endl;
-        // set the label if not set (and push on root stack as well)
-        if (FragmentSearch.Labels[OtherWalker->nr] == -1) {
-          FragmentSearch.Labels[OtherWalker->nr] = UniqueIndex++;
-          *out << Verbose(3) << "Set label to " << FragmentSearch.Labels[OtherWalker->nr] << "." << endl;
-        } else {
-          *out << Verbose(3) << "Label is already " << FragmentSearch.Labels[OtherWalker->nr] << "." << endl;
-        }
-        if ((OtherWalker != PredecessorList[AtomKeyNr]) && (OtherWalker->nr > RootKeyNr)) { // only pass through those with label bigger than Root's
-          FragmentSearch.ShortestPathList[OtherWalker->nr] = SP+1;
-          *out << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl;
-          if (FragmentSearch.ShortestPathList[OtherWalker->nr] < Order) { // only pass through those within reach of Order
-            // push for exploration on stack (only if the SP of OtherWalker is longer than of Walker! (otherwise it has been added already!)
-            if (FragmentSearch.ShortestPathList[OtherWalker->nr] > SP) {
-              if (FragmentSearch.ShortestPathList[OtherWalker->nr] < (Order-1)) {
-                *out << Verbose(3) << "Putting on atom stack for further exploration." << endl;
-                PredecessorList[OtherWalker->nr] = Walker;    // note down the one further up the exploration tree
-                AtomStack.push_back(OtherWalker->nr);
-                NumberOfAtomsSPLevel[FragmentSearch.ShortestPathList[OtherWalker->nr]]++;
-              } else {
-                *out << Verbose(3) << "Not putting on atom stack, is at end of reach." << endl;
-              }
-              // add the bond in between to the SP list
-              Binder = new bond(Walker, OtherWalker); // create a new bond in such a manner, that bond::rightatom is always the one more distant
-              add(Binder, FragmentSearch.BondsPerSPList[2*SP+1]);
-              FragmentSearch.BondsPerSPCount[SP]++;
-              *out << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP] << " item(s)." << endl;
-            } else *out << Verbose(3) << "Not putting on atom stack, nor adding bond, as " << *OtherWalker << "'s SP is shorter than Walker's." << endl;
-          } else *out << Verbose(3) << "Not continuing, as " << *OtherWalker << " is out of reach of order " << Order << "." << endl;
-        } else *out << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->nr << " is smaller than that of Root " << RootKeyNr << " or this is my predecessor." << endl;
-      } else *out << Verbose(2) << "Is not in the restricted keyset or skipping hydrogen " << *OtherWalker << "." << endl;
-    }
-  }
-  // reset predecessor list
-  for(int i=0;i<Order;i++) {
-    Binder = FragmentSearch.BondsPerSPList[2*i];
-    *out << Verbose(1) << "Current SP level is " << i << "." << endl;
-    while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) {
-      Binder = Binder->next;
-      PredecessorList[Binder->rightatom->nr] = NULL;  // By construction "OtherAtom" is always Bond::rightatom!
-    } 
-  }
-  *out << endl;
+    } else
+      *out << "." << endl;
+
+    RemainingWalkers = FragmentSearch.BondsPerSPCount[SP];
+    CurrentEdge = FragmentSearch.BondsPerSPList[2*SP];    /// start of this SP level's list
+    while (CurrentEdge->next != FragmentSearch.BondsPerSPList[2*SP+1]) {    /// end of this SP level's list
+      CurrentEdge = CurrentEdge->next;
+      RemainingWalkers--;
+      Walker = CurrentEdge->rightatom;    // rightatom is always the one more distant
+      Predecessor = CurrentEdge->leftatom;    // ... and leftatom is predecessor
+      AtomKeyNr = Walker->nr;
+      *out << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and label " << FragmentSearch.Labels[AtomKeyNr] << " and SP of " << SP << ", with " << RemainingWalkers << " remaining walkers on this level." << endl;
+      // check for new sp level
+      // go through all its bonds
+      *out << Verbose(1) << "Going through all bonds of Walker." << endl;
+      for (int i=0;i<NumberOfBondsPerAtom[AtomKeyNr];i++) {
+        Binder = ListOfBondsPerAtom[AtomKeyNr][i];
+        OtherWalker = Binder->GetOtherAtom(Walker);
+        if ((RestrictedKeySet.find(OtherWalker->nr) != RestrictedKeySet.end())
+  #ifdef ADDHYDROGEN
+         && (OtherWalker->type->Z != 1)
+  #endif
+                                                              ) {  // skip hydrogens and restrict to fragment
+          *out << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *Binder << "." << endl;
+          // set the label if not set (and push on root stack as well)
+          if (FragmentSearch.Labels[OtherWalker->nr] == -1) {
+            FragmentSearch.Labels[OtherWalker->nr] = UniqueIndex++;
+            *out << Verbose(3) << "Set label to " << FragmentSearch.Labels[OtherWalker->nr] << "." << endl;
+          } else {
+            *out << Verbose(3) << "Label is already " << FragmentSearch.Labels[OtherWalker->nr] << "." << endl;
+          }
+          if ((OtherWalker != Predecessor) && (OtherWalker->nr > RootKeyNr)) { // only pass through those with label bigger than Root's
+            FragmentSearch.ShortestPathList[OtherWalker->nr] = SP+1;
+            *out << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl;
+            // add the bond in between to the SP list
+            Binder = new bond(Walker, OtherWalker); // create a new bond in such a manner, that bond::rightatom is always the one more distant
+            add(Binder, FragmentSearch.BondsPerSPList[2*(SP+1)+1]);
+            FragmentSearch.BondsPerSPCount[SP+1]++;
+            *out << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl;
+          } else *out << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->nr << " is smaller than that of Root " << RootKeyNr << " or this is my predecessor " << *Predecessor << "." << endl;
+        } else *out << Verbose(2) << "Is not in the restricted keyset or skipping hydrogen " << *OtherWalker << "." << endl;
+      }
+    }
+  }
   
   // outputting all list for debugging
   *out << Verbose(0) << "Printing all found lists." << endl;
-  for(int i=0;i<Order;i++) {
+  for(int i=1;i<Order;i++) {    // skip the root edge in the printing
     Binder = FragmentSearch.BondsPerSPList[2*i];
     *out << Verbose(1) << "Current SP level is " << i << "." << endl;
@@ -3715,5 +3764,5 @@
   
   // creating fragments with the found edge sets  (may be done in reverse order, faster)
-  SP = 0;
+  SP = -1;  // the Root <-> Root edge must be subtracted!
   for(int i=Order;i--;) { // sum up all found edges
     Binder = FragmentSearch.BondsPerSPList[2*i];
@@ -3728,27 +3777,12 @@
     *out << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl;
     FragmentSearch.FragmentSet->clear();  
-    FragmentSearch.FragmentSet->insert(FragmentSearch.Root->nr);
+    *out << Verbose(0) << "Preparing subset for this root and calling generator." << endl;
+    // prepare the subset and call the generator
+    BondsList = (bond **) Malloc(sizeof(bond *)*FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList");
+    BondsList[0] = FragmentSearch.BondsPerSPList[0]->next;  // on SP level 0 there's only the root bond
     
-    if (FragmentSearch.FragmentSet->size() == (unsigned int) Order) {
-      *out << Verbose(0) << "Enough items on stack already for a fragment!" << endl;
-      // store fragment as a KeySet
-      *out << Verbose(2) << "Found a new fragment[" << FragmentSearch.FragmentCounter << "], local nr.s are: ";
-      for(KeySet::iterator runner = FragmentSearch.FragmentSet->begin(); runner != FragmentSearch.FragmentSet->end(); runner++) {
-        *out << (*runner) << " "; 
-      }
-      *out << endl;
-      InsertFragmentIntoGraph(out, &FragmentSearch);
-    } else {
-      *out << Verbose(0) << "Preparing subset for this root and calling generator." << endl;
-      // prepare the subset and call the generator
-      BondsList = (bond **) Malloc(sizeof(bond *)*FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList");
-      Binder = FragmentSearch.BondsPerSPList[0];
-      for(int i=0;i<FragmentSearch.BondsPerSPCount[0];i++) {
-        Binder = Binder->next;
-        BondsList[i] = Binder;
-      }
-      SPFragmentGenerator(out, &FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order-1);  
-      Free((void **)&BondsList, "molecule::PowerSetGenerator: **BondsList");
-    }
+    SPFragmentGenerator(out, &FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order);
+    
+    Free((void **)&BondsList, "molecule::PowerSetGenerator: **BondsList");
   } else {
     *out << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl;
@@ -3777,8 +3811,4 @@
   }
 
-  // free allocated memory
-  Free((void **)&NumberOfAtomsSPLevel, "molecule::PowerSetGenerator: *SPLevelCount");
-  Free((void **)&PredecessorList, "molecule::PowerSetGenerator: **PredecessorList");
-  
   // return list  
   *out << Verbose(0) << "End of PowerSetGenerator." << endl;
@@ -4039,7 +4069,8 @@
     Walker = FindAtom(RootKeyNr);
     // check cyclic lengths
-    if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
-      *out << Verbose(0) << "Bond order " << Walker->GetTrueFather()->AdaptiveOrder << " of Root " << *Walker << " greater than or equal to Minimum Ring size of " << MinimumRingSize << " found is not allowed." << endl;
-    } else {
+    //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
+    //  *out << Verbose(0) << "Bond order " << Walker->GetTrueFather()->AdaptiveOrder << " of Root " << *Walker << " greater than or equal to Minimum Ring size of " << MinimumRingSize << " found is not allowed." << endl;
+    //} else 
+    {
       // increase adaptive order by one
       Walker->GetTrueFather()->AdaptiveOrder++;
@@ -4060,8 +4091,10 @@
       NumLevels = 1 << (Order-1); // (int)pow(2,Order);
       FragmentLowerOrdersList[RootNr] = (Graph **) Malloc(sizeof(Graph *)*NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]");
+      for (int i=0;i<NumLevels;i++)
+        FragmentLowerOrdersList[RootNr][i] = NULL;
       
       // create top order where nothing is reduced
       *out << Verbose(0) << "==============================================================================================================" << endl;
-      *out << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", NumLevels is " << NumLevels << ", " << (RootStack.size()-RootNr-1) << " Roots remaining." << endl;
+      *out << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", NumLevels is " << NumLevels << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl;
   
       // Create list of Graphs of current Bond Order (i.e. F_{ij})
@@ -4072,39 +4105,43 @@
       NumMoleculesOfOrder[RootNr] = PowerSetGenerator(out, Walker->AdaptiveOrder, FragmentSearch, CompleteMolecule);
       *out << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl;
-      NumMolecules = 0;
-      
-      if ((NumLevels >> 1) > 0) {
-        // create lower order fragments
-        *out << Verbose(0) << "Creating list of unique fragments of lower Bond Order terms to be subtracted." << endl;
-        Order = Walker->AdaptiveOrder;
-        for (int source=0;source<(NumLevels >> 1);source++) { // 1-terms don't need any more splitting, that's why only half is gone through (shift again)
-          // step down to next order at (virtual) boundary of powers of 2 in array
-          while (source >= (1 << (Walker->AdaptiveOrder-Order))) // (int)pow(2,Walker->AdaptiveOrder-Order))    
-            Order--;
-          *out << Verbose(0) << "Current Order is: " << Order << "." << endl;
-          for (int SubOrder=Order-1;SubOrder>0;SubOrder--) {
-            int dest = source + (1 << (Walker->AdaptiveOrder-(SubOrder+1)));
-            *out << Verbose(0) << "--------------------------------------------------------------------------------------------------------------" << endl;
-            *out << Verbose(0) << "Current SubOrder is: " << SubOrder << " with source " << source << " to destination " << dest << "." << endl;
-      
-            // every molecule is split into a list of again (Order - 1) molecules, while counting all molecules
-            //*out << Verbose(1) << "Splitting the " << (*FragmentLowerOrdersList[RootNr][source]).size() << " molecules of the " << source << "th cell in the array." << endl;
-            //NumMolecules = 0;
-            FragmentLowerOrdersList[RootNr][dest] = new Graph;
-            for(Graph::iterator runner = (*FragmentLowerOrdersList[RootNr][source]).begin();runner != (*FragmentLowerOrdersList[RootNr][source]).end(); runner++) {
-              for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) {
-                Graph TempFragmentList;
-                FragmentSearch.TEFactor = -(*runner).second.second;
-                FragmentSearch.Leaflet = &TempFragmentList;      // set to insertion graph
-                FragmentSearch.Root = FindAtom(*sprinter);
-                NumMoleculesOfOrder[RootNr] += PowerSetGenerator(out, SubOrder, FragmentSearch, (*runner).first);
-                // insert new keysets FragmentList into FragmentLowerOrdersList[Walker->AdaptiveOrder-1][dest]
-                *out << Verbose(1) << "Merging resulting key sets with those present in destination " << dest << "." << endl;
-                InsertGraphIntoGraph(out, *FragmentLowerOrdersList[RootNr][dest], TempFragmentList, &NumMolecules);
+      if (NumMoleculesOfOrder[RootNr] != 0) {
+        NumMolecules = 0;
+        
+        if ((NumLevels >> 1) > 0) {
+          // create lower order fragments
+          *out << Verbose(0) << "Creating list of unique fragments of lower Bond Order terms to be subtracted." << endl;
+          Order = Walker->AdaptiveOrder;
+          for (int source=0;source<(NumLevels >> 1);source++) { // 1-terms don't need any more splitting, that's why only half is gone through (shift again)
+            // step down to next order at (virtual) boundary of powers of 2 in array
+            while (source >= (1 << (Walker->AdaptiveOrder-Order))) // (int)pow(2,Walker->AdaptiveOrder-Order))    
+              Order--;
+            *out << Verbose(0) << "Current Order is: " << Order << "." << endl;
+            for (int SubOrder=Order-1;SubOrder>0;SubOrder--) {
+              int dest = source + (1 << (Walker->AdaptiveOrder-(SubOrder+1)));
+              *out << Verbose(0) << "--------------------------------------------------------------------------------------------------------------" << endl;
+              *out << Verbose(0) << "Current SubOrder is: " << SubOrder << " with source " << source << " to destination " << dest << "." << endl;
+        
+              // every molecule is split into a list of again (Order - 1) molecules, while counting all molecules
+              //*out << Verbose(1) << "Splitting the " << (*FragmentLowerOrdersList[RootNr][source]).size() << " molecules of the " << source << "th cell in the array." << endl;
+              //NumMolecules = 0;
+              FragmentLowerOrdersList[RootNr][dest] = new Graph;
+              for(Graph::iterator runner = (*FragmentLowerOrdersList[RootNr][source]).begin();runner != (*FragmentLowerOrdersList[RootNr][source]).end(); runner++) {
+                for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) {
+                  Graph TempFragmentList;
+                  FragmentSearch.TEFactor = -(*runner).second.second;
+                  FragmentSearch.Leaflet = &TempFragmentList;      // set to insertion graph
+                  FragmentSearch.Root = FindAtom(*sprinter);
+                  NumMoleculesOfOrder[RootNr] += PowerSetGenerator(out, SubOrder, FragmentSearch, (*runner).first);
+                  // insert new keysets FragmentList into FragmentLowerOrdersList[Walker->AdaptiveOrder-1][dest]
+                  *out << Verbose(1) << "Merging resulting key sets with those present in destination " << dest << "." << endl;
+                  InsertGraphIntoGraph(out, *FragmentLowerOrdersList[RootNr][dest], TempFragmentList, &NumMolecules);
+                }
               }
+              *out << Verbose(1) << "Number of resulting molecules for SubOrder " << SubOrder << " is: " << NumMolecules << "." << endl;
             }
-            *out << Verbose(1) << "Number of resulting molecules for SubOrder " << SubOrder << " is: " << NumMolecules << "." << endl;
           }
         }
+      } else {
+        *out << Verbose(1) << "Hence, we don't dive into SubOrders ... " << endl;
       }
       // now, we have completely filled each cell of FragmentLowerOrdersList[] for the current Walker->AdaptiveOrder
Index: src/molecules.hpp
===================================================================
--- src/molecules.hpp	(revision af6d8f00912cd5022f1a2c33ac397ac378ec965d)
+++ src/molecules.hpp	(revision 4aa03a552cf306f8b3265e786d08e545bf01bed4)
@@ -237,4 +237,5 @@
   void ResetAllAtomNumbers();
   int CountCyclicBonds(ofstream *out);
+  bool CheckForConnectedSubgraph(ofstream *out, KeySet *Fragment);
   string GetColor(enum Shading color);
 
