Index: src/Legacy/oldmenu.cpp
===================================================================
--- src/Legacy/oldmenu.cpp	(revision 24a5e09f04efb019de433cb90728399e3a3c830a)
+++ src/Legacy/oldmenu.cpp	(revision d3347e51ec76a8b2c512f9c40cd24e2a622a37da)
@@ -447,14 +447,14 @@
       break;
     case 'b':
-      second = mol->AskAtom("Enter number of atom as reference point: ");
-      Log() << Verbose(0) << "Enter radius: ";
-      cin >> tmp1;
-      first = mol->start;
-      second = first->next;
-      while(second != mol->end) {
-        first = second;
-        second = first->next;
-        if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
-          mol->RemoveAtom(first);
+      {
+        second = mol->AskAtom("Enter number of atom as reference point: ");
+        Log() << Verbose(0) << "Enter radius: ";
+        cin >> tmp1;
+        molecule::iterator runner;
+        for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
+          runner = iter++;
+          if ((*runner)->x.DistanceSquared((const Vector *)&(*runner)->x) > tmp1*tmp1) // distance to first above radius ...
+            mol->RemoveAtom((*runner));
+        }
       }
       break;
@@ -466,12 +466,10 @@
       Log() << Verbose(0) << "Upper boundary: ";
       cin >> tmp2;
-      first = mol->start;
-      second = first->next;
-      while(second != mol->end) {
-        first = second;
-        second = first->next;
-        if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
-          //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
-          mol->RemoveAtom(first);
+      molecule::iterator runner;
+      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
+        runner = iter++;
+        if (((*runner)->x.x[axis] < tmp1) || ((*runner)->x.x[axis] > tmp2)) {// out of boundary ...
+          //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
+          mol->RemoveAtom((*runner));
         }
       }
@@ -516,16 +514,14 @@
         min[i] = 0.;
 
-      second = mol->start;
-      while ((second->next != mol->end)) {
-        second = second->next; // advance
-        Z = second->type->Z;
+      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+        Z = (*iter)->type->Z;
         tmp1 = 0.;
-        if (first != second) {
+        if (first != (*iter)) {
           x.CopyVector((const Vector *)&first->x);
-          x.SubtractVector((const Vector *)&second->x);
+          x.SubtractVector((const Vector *)&(*iter)->x);
           tmp1 = x.Norm();
         }
         if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
-        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
+        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;
       }
       for (int i=MAX_ELEMENTS;i--;)
@@ -767,9 +763,7 @@
       vectors = new Vector *[count];
       j = 0;
-      first = mol->start;
-      while (first->next != mol->end) { // make a list of all atoms with coordinates and element
-        first = first->next;
-        Elements[j] = first->type;
-        vectors[j] = &first->x;
+      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+        Elements[j] = (*iter)->type;
+        vectors[j] = &(*iter)->x;
         j++;
       }
@@ -1029,5 +1023,4 @@
     return;
   }
-  atom *Walker = mol->start;
 
   // generate some KeySets
@@ -1035,8 +1028,7 @@
   KeySet TestSets[mol->AtomCount+1];
   i=1;
-  while (Walker->next != mol->end) {
-    Walker = Walker->next;
+  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     for (int j=0;j<i;j++) {
-      TestSets[j].insert(Walker->nr);
+      TestSets[j].insert((*iter)->nr);
     }
     i++;
@@ -1044,12 +1036,15 @@
   Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
   KeySetTestPair test;
-  test = TestSets[mol->AtomCount-1].insert(Walker->nr);
-  if (test.second) {
-    Log() << Verbose(1) << "Insertion worked?!" << endl;
+  molecule::const_iterator iter = mol->begin();
+  if (iter != mol->end()) {
+    test = TestSets[mol->AtomCount-1].insert((*iter)->nr);
+    if (test.second) {
+      Log() << Verbose(1) << "Insertion worked?!" << endl;
+    } else {
+      Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
+    }
   } else {
-    Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
-  }
-  TestSets[mol->AtomCount].insert(mol->end->previous->nr);
-  TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
+    eLog() << Verbose(1) << "No atoms to test double insertion." << endl;
+  }
 
   // constructing Graph structure
