Index: src/Legacy/oldmenu.cpp
===================================================================
--- src/Legacy/oldmenu.cpp	(revision 8cbb9792c39564b3033f03b7e9dc61143585d5f4)
+++ src/Legacy/oldmenu.cpp	(revision a7b761bc6e1b696b9f7a380da8984083300d3d7b)
@@ -423,5 +423,5 @@
 void oldmenu::RemoveAtoms(molecule *mol)
 {
-  atom *first, *second;
+  atom *second;
   int axis;
   double tmp1, tmp2;
@@ -446,14 +446,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(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((*runner)->x) > tmp1*tmp1) // distance to first above radius ...
+            mol->RemoveAtom((*runner));
+        }
       }
       break;
@@ -465,12 +465,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[axis] < tmp1) || (first->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[axis] < tmp1) || ((*runner)->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));
         }
       }
@@ -515,15 +513,13 @@
         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) {
-          x = first->x - second->x;
+        if (first != (*iter)) {
+          x = first->x - (*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--;)
@@ -754,16 +750,12 @@
     Log() << Verbose(0) << "State the factor: ";
     cin >> faktor;
-
-    mol->CountAtoms(); // recount atoms
-    if (mol->AtomCount != 0) {  // if there is more than none
-      count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
+    if (mol->getAtomCount() != 0) {  // if there is more than none
+      count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
       Elements = new const element *[count];
       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++;
       }
@@ -1024,14 +1016,12 @@
     return;
   }
-  atom *Walker = mol->start;
 
   // generate some KeySets
   Log() << Verbose(0) << "Generating KeySets." << endl;
-  KeySet TestSets[mol->AtomCount+1];
+  KeySet TestSets[mol->getAtomCount()+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++;
@@ -1039,12 +1029,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->getAtomCount()-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
@@ -1054,10 +1047,10 @@
   // insert KeySets into Subgraphs
   Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
-  for (int j=0;j<mol->AtomCount;j++) {
+  for (int j=0;j<mol->getAtomCount();j++) {
     Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
   }
   Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
   GraphTestPair test2;
-  test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
+  test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
   if (test2.second) {
     Log() << Verbose(1) << "Insertion worked?!" << endl;
