Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision cee0b57afea6660531722346890ed484e9ea8dd4)
+++ src/builder.cpp	(revision ebcadedc2eb5f524f09fc7618fe9f4fea00cdbb8)
@@ -1382,6 +1382,6 @@
             cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
             cout << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
-            cout << "\t-r\t\tConvert file from an old pcp syntax." << endl;
-            cout << "\t-R\t\tRemove all atoms out of sphere around a given one." << endl;
+            cout << "\t-r <id>\t\tRemove an atom with given id." << endl;
+            cout << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl;
             cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
             cout << "\t-S <file> Store temperatures from the config file in <file>." << endl;
@@ -1480,5 +1480,5 @@
           switch(argv[argptr-1][1]) {
             case 'p':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
                 ExitFlag = 255;
@@ -1496,5 +1496,5 @@
               break;
             case 'a':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1]))) {
                 ExitFlag = 255;
@@ -1535,5 +1535,5 @@
               break;
             case 'D':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               {
                 cout << Verbose(1) << "Depth-First-Search Analysis." << endl;
@@ -1568,5 +1568,5 @@
               break;
             case 'E':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
                 ExitFlag = 255;
@@ -1581,5 +1581,5 @@
               break;
             case 'F':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if (argptr+5 >=argc) {
                 ExitFlag = 255;
@@ -1619,5 +1619,5 @@
               break;
             case 'A':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
                 ExitFlag =255;
@@ -1632,5 +1632,5 @@
               break;
             case 'N':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
                 ExitFlag = 255;
@@ -1652,5 +1652,5 @@
               break;
             case 'S':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
                 ExitFlag = 255;
@@ -1669,5 +1669,5 @@
               break;
             case 'L':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
                 ExitFlag = 255;
@@ -1686,5 +1686,5 @@
               break;
             case 'P':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
                 ExitFlag = 255;
@@ -1701,6 +1701,6 @@
               break;
             case 'R':
-              ExitFlag = 1;
-              if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl;
@@ -1726,10 +1726,10 @@
               break;
             case 't':
-              ExitFlag = 1;
-              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
               } else {
-                ExitFlag = 1;
+                if (ExitFlag == 0) ExitFlag = 1;
                 SaveFlag = true;
                 cout << Verbose(1) << "Translating all ions by given vector." << endl;
@@ -1741,10 +1741,10 @@
               break;
             case 'T':
-              ExitFlag = 1;
-              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl;
               } else {
-                ExitFlag = 1;
+                if (ExitFlag == 0) ExitFlag = 1;
                 SaveFlag = true;
                 cout << Verbose(1) << "Translating all ions periodically by given vector." << endl;
@@ -1756,6 +1756,6 @@
               break;
             case 's':
-              ExitFlag = 1;
-              if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) ) {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for scaling: -s <factor/[factor_x]> [factor_y] [factor_z]" << endl;
@@ -1783,6 +1783,6 @@
               break;
             case 'b':
-              ExitFlag = 1;
-              if ((argptr+5 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
@@ -1800,6 +1800,6 @@
               break;
             case 'B':
-              ExitFlag = 1;
-              if ((argptr+5 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
@@ -1817,6 +1817,6 @@
               break;
             case 'c':
-              ExitFlag = 1;
-              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
@@ -1841,5 +1841,5 @@
               break;
             case 'O':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               SaveFlag = true;
               cout << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl;
@@ -1850,11 +1850,19 @@
               break;
             case 'r':
-              ExitFlag = 1;
-              SaveFlag = true;
-              cout << Verbose(1) << "Converting config file from supposed old to new syntax." << endl;
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])))  {
+                ExitFlag = 255;
+                cerr << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl;
+              } else {
+                SaveFlag = true;
+                cout << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl;
+                atom *first = mol->FindAtom(atoi(argv[argptr]));
+                mol->RemoveAtom(first);
+                argptr+=1;
+              }
               break;
             case 'f':
-              ExitFlag = 1;
-              if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
@@ -1874,5 +1882,5 @@
               break;
             case 'm':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               j = atoi(argv[argptr++]);
               if ((j<0) || (j>1)) {
@@ -1888,5 +1896,5 @@
               break;
             case 'o':
-              ExitFlag = 1;
+              if (ExitFlag == 0) ExitFlag = 1;
               if ((argptr+1 >= argc) || (argv[argptr][0] == '-')){
                 ExitFlag = 255;
@@ -1908,6 +1916,6 @@
               break;
             case 'U':
-              ExitFlag = 1;
-              if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
@@ -1918,6 +1926,6 @@
               }
             case 'u':
-              ExitFlag = 1;
-              if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) ) {
                 if (volume != -1)
                   ExitFlag = 255;
@@ -1942,6 +1950,6 @@
               break;
             case 'd':
-              ExitFlag = 1;
-              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
+              if (ExitFlag == 0) ExitFlag = 1;
+              if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
                 ExitFlag = 255;
                 cerr << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
