Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision 42af9ec72d1b004ed85b6db33bdcaeeecd94a23a)
+++ src/builder.cpp	(revision 1024cbc27eef62ed70b770868d078bd3df38ada6)
@@ -865,6 +865,6 @@
 
         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 element *[count];
           vectors = new Vector *[count];
@@ -1296,5 +1296,5 @@
   // generate some KeySets
   DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);
-  KeySet TestSets[mol->AtomCount+1];
+  KeySet TestSets[mol->getAtomCount()+1];
   i=1;
   while (Walker->next != mol->end) {
@@ -1307,5 +1307,5 @@
   DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);
   KeySetTestPair test;
-  test = TestSets[mol->AtomCount-1].insert(Walker->nr);
+  test = TestSets[mol->getAtomCount()-1].insert(Walker->nr);
   if (test.second) {
     DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
@@ -1313,6 +1313,6 @@
     DoLog(1) && (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);
+  TestSets[mol->getAtomCount()].insert(mol->end->previous->nr);
+  TestSets[mol->getAtomCount()].insert(mol->end->previous->previous->previous->nr);
 
   // constructing Graph structure
@@ -1322,10 +1322,10 @@
   // insert KeySets into Subgraphs
   DoLog(0) && (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.)));
   }
   DoLog(0) && (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) {
     DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
@@ -1714,5 +1714,5 @@
                 if (first->type != NULL) {
                   mol->AddAtom(first);  // add to molecule
-                  if ((configPresent == empty) && (mol->AtomCount != 0))
+                  if ((configPresent == empty) && (mol->getAtomCount() != 0))
                     configPresent = present;
                 } else
@@ -1732,5 +1732,5 @@
                 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
                 MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
-                int *MinimumRingSize = new int[mol->AtomCount];
+                int *MinimumRingSize = new int[mol->getAtomCount()];
                 atom ***ListOfLocalAtoms = NULL;
                 class StackClass<bond *> *BackEdgeStack = NULL;
@@ -1880,5 +1880,5 @@
                           int counter  = 0;
                           for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
-                            if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
+                            if ((Boundary == NULL) || (Boundary->getAtomCount() < (*BigFinder)->getAtomCount())) {
                               Boundary = *BigFinder;
                             }
@@ -1939,4 +1939,5 @@
                 performCriticalExit();
               } else {
+                mol->getAtomCount();
                 SaveFlag = true;
                 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl);
@@ -2042,11 +2043,10 @@
                 int counter  = 0;
                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
-                  (*BigFinder)->CountAtoms();
-                  if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
+                  if ((Boundary == NULL) || (Boundary->getAtomCount() < (*BigFinder)->getAtomCount())) {
                     Boundary = *BigFinder;
                   }
                   counter++;
                 }
-                DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl);
+                DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->getAtomCount() << " atoms." << endl);
                 start = clock();
                 LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
@@ -2115,27 +2115,25 @@
             case 'R':
               if (ExitFlag == 0) ExitFlag = 1;
-              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
+              if ((argptr+3 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])))  {
                 ExitFlag = 255;
-                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl);
+                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <x> <y> <z> <distance>" << endl);
                 performCriticalExit();
               } else {
                 SaveFlag = true;
-                DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl);
-                double tmp1 = atof(argv[argptr+1]);
-                atom *third = mol->FindAtom(atoi(argv[argptr]));
-                atom *first = mol->start;
-                if ((third != NULL) && (first != mol->end)) {
-                  atom *second = first->next;
-                  while(second != mol->end) {
-                    first = second;
-                    second = first->next;
-                    if (first->x.DistanceSquared(third->x) > tmp1*tmp1) {// distance to first above radius ...
-                      mol->RemoveAtom(first);
-                    }
+                const double radius = atof(argv[argptr+3]);
+                Vector point(atof(argv[argptr]),atof(argv[argptr+1]),atof(argv[argptr+2]));
+                DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl);
+                atom *Walker = NULL;
+                molecule::iterator advancer = mol->begin();
+                for(molecule::iterator iter = advancer; advancer != mol->end();) {
+                  iter = advancer++;
+                  if ((*iter)->x.DistanceSquared(point) > radius*radius){ // distance to first above radius ...
+                    Walker = (*iter);
+                    DoLog(1) && (Log() << Verbose(1) << "Removing atom " << *Walker << "." << endl);
+                    mol->RemoveAtom(*(iter));
+                    World::getInstance().destroyAtom(Walker);
                   }
-                } else {
-                  DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);
                 }
-                argptr+=2;
+                argptr+=4;
               }
               break;
@@ -2262,4 +2260,5 @@
                 performCriticalExit();
               } else {
+                mol->getAtomCount();
                 SaveFlag = true;
                 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl);
@@ -2381,15 +2380,12 @@
                     faktor = 1;
                   }
-                  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::iterator iter = mol->begin();iter!=mol->end();++iter){
+                      Elements[j] = (*iter)->type;
+                      vectors[j] = &(*iter)->x;
                       j++;
                     }
@@ -2458,4 +2454,7 @@
 {
     config *configuration = World::getInstance().getConfig();
+    // while we are non interactive, we want to abort from asserts
+    //ASSERT_DO(Assert::Abort);
+    molecule *mol = NULL;
     Vector x, y, z, n;
     ifstream test;
@@ -2481,4 +2480,7 @@
     // need to init the history before any action is created
     ActionHistory::init();
+
+    // In the interactive mode, we can leave the user the choice in case of error
+    ASSERT_DO(Assert::Ask);
 
     // from this moment on, we need to be sure to deeinitialize in the correct order
