Index: src/molecule_graph.cpp
===================================================================
--- src/molecule_graph.cpp	(revision 266237a46efdbba0be37a76f5e86b6814aac18d7)
+++ src/molecule_graph.cpp	(revision 174e0ece471da3cb17f2cbf08ba655f90c27f316)
@@ -252,4 +252,115 @@
 };
 
+void SetWalkersGraphNr(ofstream *out, bool &BackStepping, atom *&Walker, int &CurrentGraphNr, class StackClass<atom *> *&AtomStack)
+{
+  if (!BackStepping) { // if we don't just return from (8)
+    Walker->GraphNr = CurrentGraphNr;
+    Walker->LowpointNr = CurrentGraphNr;
+    *out << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl;
+    AtomStack->Push(Walker);
+    CurrentGraphNr++;
+  }
+};
+
+void ProbeAlongUnusedBond(ofstream *out, molecule *mol, bond *&Binder, bool &BackStepping, atom *&Walker, class StackClass<bond *> *&BackEdgeStack)
+{
+  atom *OtherAtom = NULL;
+
+  do { // (3) if Walker has no unused egdes, go to (5)
+    BackStepping = false; // reset backstepping flag for (8)
+    if (Binder == NULL) // if we don't just return from (11), Binder is already set to next unused
+      Binder = mol->FindNextUnused(Walker);
+    if (Binder == NULL)
+      break;
+    *out << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl;
+    // (4) Mark Binder used, ...
+    Binder->MarkUsed(black);
+    OtherAtom = Binder->GetOtherAtom(Walker);
+    *out << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl;
+    if (OtherAtom->GraphNr != -1) {
+      // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
+      Binder->Type = BackEdge;
+      BackEdgeStack->Push(Binder);
+      Walker->LowpointNr = ( Walker->LowpointNr < OtherAtom->GraphNr ) ? Walker->LowpointNr : OtherAtom->GraphNr;
+      *out << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl;
+    } else {
+      // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2)
+      Binder->Type = TreeEdge;
+      OtherAtom->Ancestor = Walker;
+      Walker = OtherAtom;
+      *out << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl;
+      break;
+    }
+    Binder = NULL;
+  } while (1);  // (3)
+};
+
+void CheckForaNewComponent(ofstream *out, molecule *mol, bool &BackStepping, atom *&Walker, atom *&Root, int &ComponentNumber, class StackClass<atom *> *&AtomStack, MoleculeLeafClass *&LeafWalker )
+{
+  atom *OtherAtom = NULL;
+
+  // (5) if Ancestor of Walker is ...
+  *out << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl;
+
+  if (Walker->Ancestor->GraphNr != Root->GraphNr) {
+    // (6)  (Ancestor of Walker is not Root)
+    if (Walker->LowpointNr < Walker->Ancestor->GraphNr) {
+      // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8)
+      Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr;
+      *out << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl;
+    } else {
+      // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component
+      Walker->Ancestor->SeparationVertex = true;
+      *out << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl;
+      mol->SetNextComponentNumber(Walker->Ancestor, ComponentNumber);
+      *out << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << ComponentNumber << "." << endl;
+      mol->SetNextComponentNumber(Walker, ComponentNumber);
+      *out << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << ComponentNumber << "." << endl;
+      do {
+        OtherAtom = AtomStack->PopLast();
+        LeafWalker->Leaf->AddCopyAtom(OtherAtom);
+        mol->SetNextComponentNumber(OtherAtom, ComponentNumber);
+        *out << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << ComponentNumber << "." << endl;
+      } while (OtherAtom != Walker);
+      ComponentNumber++;
+    }
+    // (8) Walker becomes its Ancestor, go to (3)
+    *out << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl;
+    Walker = Walker->Ancestor;
+    BackStepping = true;
+  }
+};
+
+void CleanRootStackDownTillWalker(ofstream *out, molecule *mol, bool &BackStepping, atom *&Root, atom *&Walker, bond *&Binder, int &ComponentNumber, class StackClass<atom *> *&AtomStack, MoleculeLeafClass *&LeafWalker)
+{
+  atom *OtherAtom = NULL;
+
+  if (!BackStepping) {  // coming from (8) want to go to (3)
+    // (9) remove all from stack till Walker (including), these and Root form a component
+    AtomStack->Output(out);
+    mol->SetNextComponentNumber(Root, ComponentNumber);
+    *out << Verbose(3) << "(9) Root[" << Root->Name << "]'s Component is " << ComponentNumber << "." << endl;
+    mol->SetNextComponentNumber(Walker, ComponentNumber);
+    *out << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << ComponentNumber << "." << endl;
+    do {
+      OtherAtom = AtomStack->PopLast();
+      LeafWalker->Leaf->AddCopyAtom(OtherAtom);
+      mol->SetNextComponentNumber(OtherAtom, ComponentNumber);
+      *out << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << ComponentNumber << "." << endl;
+    } while (OtherAtom != Walker);
+    ComponentNumber++;
+
+    // (11) Root is separation vertex,  set Walker to Root and go to (4)
+    Walker = Root;
+    Binder = mol->FindNextUnused(Walker);
+    *out << Verbose(1) << "(10) Walker is Root[" << Root->Name << "], next Unused Bond is " << Binder << "." << endl;
+    if (Binder != NULL) { // Root is separation vertex
+      *out << Verbose(1) << "(11) Root is a separation vertex." << endl;
+      Walker->SeparationVertex = true;
+    }
+  }
+};
+
+
 /** Performs a Depth-First search on this molecule.
  * Marks bonds in molecule as cyclic, bridge, ... and atoms as
@@ -268,5 +379,6 @@
   int CurrentGraphNr = 0, OldGraphNr;
   int ComponentNumber = 0;
-  atom *Walker = NULL, *OtherAtom = NULL, *Root = start->next;
+  atom *Walker = NULL;
+  atom *Root = start->next;
   bond *Binder = NULL;
   bool BackStepping = false;
@@ -291,38 +403,8 @@
     do { // (10)
       do { // (2) set number and Lowpoint of Atom to i, increase i, push current atom
-        if (!BackStepping) { // if we don't just return from (8)
-          Walker->GraphNr = CurrentGraphNr;
-          Walker->LowpointNr = CurrentGraphNr;
-          *out << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl;
-          AtomStack->Push(Walker);
-          CurrentGraphNr++;
-        }
-        do { // (3) if Walker has no unused egdes, go to (5)
-          BackStepping = false; // reset backstepping flag for (8)
-          if (Binder == NULL) // if we don't just return from (11), Binder is already set to next unused
-            Binder = FindNextUnused(Walker);
-          if (Binder == NULL)
-            break;
-          *out << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl;
-          // (4) Mark Binder used, ...
-          Binder->MarkUsed(black);
-          OtherAtom = Binder->GetOtherAtom(Walker);
-          *out << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl;
-          if (OtherAtom->GraphNr != -1) {
-            // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
-            Binder->Type = BackEdge;
-            BackEdgeStack->Push(Binder);
-            Walker->LowpointNr = ( Walker->LowpointNr < OtherAtom->GraphNr ) ? Walker->LowpointNr : OtherAtom->GraphNr;
-            *out << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl;
-          } else {
-            // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2)
-            Binder->Type = TreeEdge;
-            OtherAtom->Ancestor = Walker;
-            Walker = OtherAtom;
-            *out << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl;
-            break;
-          }
-          Binder = NULL;
-        } while (1);  // (3)
+        SetWalkersGraphNr(out, BackStepping, Walker, CurrentGraphNr, AtomStack);
+
+        ProbeAlongUnusedBond(out, this, Binder, BackStepping, Walker, BackEdgeStack);
+
         if (Binder == NULL) {
           *out << Verbose(2) << "No more Unused Bonds." << endl;
@@ -336,57 +418,8 @@
         break;
 
-      // (5) if Ancestor of Walker is ...
-      *out << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl;
-      if (Walker->Ancestor->GraphNr != Root->GraphNr) {
-        // (6)  (Ancestor of Walker is not Root)
-        if (Walker->LowpointNr < Walker->Ancestor->GraphNr) {
-          // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8)
-          Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr;
-          *out << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl;
-        } else {
-          // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component
-          Walker->Ancestor->SeparationVertex = true;
-          *out << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl;
-          SetNextComponentNumber(Walker->Ancestor, ComponentNumber);
-          *out << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << ComponentNumber << "." << endl;
-          SetNextComponentNumber(Walker, ComponentNumber);
-          *out << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << ComponentNumber << "." << endl;
-          do {
-            OtherAtom = AtomStack->PopLast();
-            LeafWalker->Leaf->AddCopyAtom(OtherAtom);
-            SetNextComponentNumber(OtherAtom, ComponentNumber);
-            *out << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << ComponentNumber << "." << endl;
-          } while (OtherAtom != Walker);
-          ComponentNumber++;
-        }
-        // (8) Walker becomes its Ancestor, go to (3)
-        *out << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl;
-        Walker = Walker->Ancestor;
-        BackStepping = true;
-      }
-      if (!BackStepping) {  // coming from (8) want to go to (3)
-        // (9) remove all from stack till Walker (including), these and Root form a component
-        AtomStack->Output(out);
-        SetNextComponentNumber(Root, ComponentNumber);
-        *out << Verbose(3) << "(9) Root[" << Root->Name << "]'s Component is " << ComponentNumber << "." << endl;
-        SetNextComponentNumber(Walker, ComponentNumber);
-        *out << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << ComponentNumber << "." << endl;
-        do {
-          OtherAtom = AtomStack->PopLast();
-          LeafWalker->Leaf->AddCopyAtom(OtherAtom);
-          SetNextComponentNumber(OtherAtom, ComponentNumber);
-          *out << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << ComponentNumber << "." << endl;
-        } while (OtherAtom != Walker);
-        ComponentNumber++;
-
-        // (11) Root is separation vertex,  set Walker to Root and go to (4)
-        Walker = Root;
-        Binder = FindNextUnused(Walker);
-        *out << Verbose(1) << "(10) Walker is Root[" << Root->Name << "], next Unused Bond is " << Binder << "." << endl;
-        if (Binder != NULL) { // Root is separation vertex
-          *out << Verbose(1) << "(11) Root is a separation vertex." << endl;
-          Walker->SeparationVertex = true;
-        }
-      }
+      CheckForaNewComponent(out, this, BackStepping, Walker, Root,ComponentNumber, AtomStack, LeafWalker );
+
+      CleanRootStackDownTillWalker(out, this, BackStepping, Root, Walker, Binder, ComponentNumber, AtomStack, LeafWalker);
+
     } while ((BackStepping) || (Binder != NULL)); // (10) halt only if Root has no unused edges
 
