Index: src/Actions/MapOfActions.cpp
===================================================================
--- src/Actions/MapOfActions.cpp	(revision 1e6913b9968cc6beb553ca42434c08a099e00d98)
+++ src/Actions/MapOfActions.cpp	(revision 58bbd3f2e470541a11fee67100edb3e8b589c40f)
@@ -50,5 +50,4 @@
   v = boost::any(BoxValue(BV));
 }
-
 
 /** Constructor of class MapOfActions.
@@ -85,7 +84,5 @@
   DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
   DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
-  DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements";
-  DescriptionMap["pair-correlation-point"] = "pair correlation analysis between atoms of a element to a given point";
-  DescriptionMap["pair-correlation-surface"] = "pair correlation analysis between atoms of a given element and a surface";
+  DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface";
   DescriptionMap["parse-xyz"] = "parse xyz file into World";
   DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
@@ -113,5 +110,6 @@
   DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction";
   DescriptionMap["DoRotate"] = "whether to rotate or just report angles";
-  DescriptionMap["element"] = "set of elements";
+  DescriptionMap["element"] = "single element";
+  DescriptionMap["elements"] = "set of elements";
   DescriptionMap["end-mol"] = "last or end step";
   DescriptionMap["input"] = "name of input file";
@@ -120,4 +118,5 @@
   DescriptionMap["MaxDistance"] = "maximum distance in space";
   DescriptionMap["molecule-by-id"] = "index of a molecule";
+  DescriptionMap["molecule-by-name"] = "name of a molecule";
   DescriptionMap["order"] = "order of a discretization, dissection, ...";
   DescriptionMap["output-file"] = "name of the output file";
@@ -146,7 +145,5 @@
   ShortFormMap["linear-interpolate"] = "L";
   ShortFormMap["nonconvex-envelope"] = "N";
-  ShortFormMap["pair-correlation"] = "CE";
-  ShortFormMap["pair-correlation-point"] = "CP";
-  ShortFormMap["pair-correlation-surface"] = "CS";
+  ShortFormMap["pair-correlation"] = "C";
   ShortFormMap["parse-xyz"] = "p";
   ShortFormMap["remove-atom"] = "r";
@@ -188,4 +185,5 @@
   TypeMap["nonconvex-envelope"] = Molecule;
   TypeMap["parse-xyz"] = String;
+  TypeMap["pair-correlation"] = String;
   TypeMap["principal-axis-system"] = Axis;
   TypeMap["remove-atom"] = Atom;
@@ -208,4 +206,5 @@
   TypeMap["bin-end"] = Double;
   TypeMap["bin-start"] = Double;
+  TypeMap["bin-width"] = Double;
   TypeMap["distance"] = Double;
   TypeMap["distances"] = Vector;
@@ -217,4 +216,5 @@
   TypeMap["MaxDistance"] = Double;
   TypeMap["molecule-by-id"] = Molecule;
+  TypeMap["molecule-by-name"] = Molecule;
   TypeMap["order"] = Integer;
   TypeMap["output-file"] = String;
@@ -224,4 +224,6 @@
   // default values for any action that needs one (always string!)
   DefaultValue["molecule-by-id"] = "-1";
+  DefaultValue["bin-width"] = "0.5";
+  DefaultValue["periodic"] = "0";
 
 
@@ -240,5 +242,5 @@
 //	generic.insert("default-molname");
 	generic.insert("depth-first-search");
-//	generic.insert("element-db");
+//	generic.insert("element-d<b");
 //	generic.insert("fastparsing");
   generic.insert("fill-molecule");
@@ -248,7 +250,5 @@
 //  generic.insert("molecular-volume");
 //  generic.insert("nonconvex-envelope");
-//	generic.insert("pair-correlation");
-//	generic.insert("pair-correlation-point");
-//	generic.insert("pair-correlation-surface");
+	generic.insert("pair-correlation");
 //	generic.insert("parse-xyz");
 //  generic.insert("principal-axis-system");
@@ -269,7 +269,4 @@
 	generic.insert("version");
 //	// list of generic values
-//	generic.insert("bin-output-file");
-//  generic.insert("bin-end");
-//  generic.insert("bin-start");
 //  generic.insert("distance");
 //  generic.insert("distances");
@@ -278,7 +275,4 @@
     generic.insert("input");
 //  generic.insert("length");
-//  generic.insert("output-file");
-//  generic.insert("periodic");
-//  generic.insert("position");
 //  generic.insert("start-mol");
 
@@ -287,11 +281,21 @@
 
     // hidden arguments
+  generic.insert("bin-end");
+  generic.insert("bin-output-file");
+  generic.insert("bin-start");
+  generic.insert("bin-width");
   generic.insert("distance");
   generic.insert("DoRotate");
   generic.insert("distances");
+  generic.insert("element");
+  generic.insert("elements");
   generic.insert("lengths");
   generic.insert("MaxDistance");
   generic.insert("molecule-by-id");
+  generic.insert("molecule-by-name");
   generic.insert("order");
+  generic.insert("output-file");
+  generic.insert("periodic");
+  generic.insert("position");
 }
 
Index: src/analysis_correlation.cpp
===================================================================
--- src/analysis_correlation.cpp	(revision 1e6913b9968cc6beb553ca42434c08a099e00d98)
+++ src/analysis_correlation.cpp	(revision 58bbd3f2e470541a11fee67100edb3e8b589c40f)
@@ -179,50 +179,4 @@
   }
 
-//  outmap = new PairCorrelationMap;
-//  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
-//    if ((*MolWalker)->ActiveFlag) {
-//      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
-//      double * FullInverseMatrix = InverseMatrix(FullMatrix);
-//      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
-//      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
-//        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
-//        if ((type1 == NULL) || ((*iter)->type == type1)) {
-//          periodicX = *(*iter)->node;
-//          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
-//          // go through every range in xyz and get distance
-//          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
-//            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
-//              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
-//                checkX = Vector(n[0], n[1], n[2]) + periodicX;
-//                checkX.MatrixMultiplication(FullMatrix);
-//                for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
-//                  if ((*MolOtherWalker)->ActiveFlag) {
-//                    DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
-//                    for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
-//                      DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
-//                      if ((*iter)->nr < (*runner)->nr)
-//                        if ((type2 == NULL) || ((*runner)->type == type2)) {
-//                          periodicOtherX = *(*runner)->node;
-//                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
-//                          // go through every range in xyz and get distance
-//                          for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++)
-//                            for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
-//                              for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
-//                                checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX;
-//                                checkOtherX.MatrixMultiplication(FullMatrix);
-//                                distance = checkX.distance(checkOtherX);
-//                                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
-//                                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
-//                              }
-//                        }
-//                  }
-//              }
-//            }
-//        }
-//      }
-//      delete[](FullMatrix);
-//      delete[](FullInverseMatrix);
-//    }
-
   return outmap;
 };
@@ -239,4 +193,5 @@
   CorrelationToPointMap *outmap = NULL;
   double distance = 0.;
+  double *cell_size = World::getInstance().getDomain();
 
   if (molecules->ListOfMolecules.empty()) {
@@ -254,5 +209,5 @@
         for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
           if ((*type == NULL) || ((*iter)->type == *type)) {
-            distance = (*iter)->node->PeriodicDistance(*point, World::getInstance().getDomain());
+            distance = (*iter)->node->PeriodicDistance(*point, cell_size);
             DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
             outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision 1e6913b9968cc6beb553ca42434c08a099e00d98)
+++ src/builder.cpp	(revision 58bbd3f2e470541a11fee67100edb3e8b589c40f)
@@ -1763,139 +1763,58 @@
                   switch(argv[argptr][0]) {
                     case 'E':
-                      {
-                        if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+2])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-')) {
-                          ExitFlag = 255;
-                          DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output> <binstart> <binend>" << endl);
-                          performCriticalExit();
-                        } else {
-                          ofstream output(argv[argptr+3]);
-                          ofstream binoutput(argv[argptr+4]);
-                          const double BinStart = atof(argv[argptr+5]);
-                          const double BinEnd = atof(argv[argptr+6]);
-
-                          std::vector<element *> elements;
-                          elements.push_back(periode->FindElement((const int) atoi(argv[argptr+1])));
-                          elements.push_back(periode->FindElement((const int) atoi(argv[argptr+2])));
-                          PairCorrelationMap *correlationmap = NULL;
-                          if (periodic)
-                            correlationmap = PeriodicPairCorrelation(molecules, elements, ranges);
-                          else
-                            correlationmap = PairCorrelation(molecules, elements);
-                          OutputPairCorrelation(&output, correlationmap);
-                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
-                          OutputCorrelation ( &binoutput, binmap );
-                          output.close();
-                          binoutput.close();
-                          delete(binmap);
-                          delete(correlationmap);
-                          argptr+=7;
-                        }
-                      }
+                      ArgcList.insert(argptr-1);
+                      ArgcList.insert(argptr);
+                      ArgcList.insert(argptr+1);
+                      ArgcList.insert(argptr+2);
+                      ArgcList.insert(argptr+3);
+                      ArgcList.insert(argptr+4);
+                      ArgcList.insert(argptr+5);
+                      ArgcList.insert(argptr+6);
+                      ArgcList.insert(argptr+7);
+                      ArgcList.insert(argptr+8);
+                      ArgcList.insert(argptr+9);
+                      ArgcList.insert(argptr+10);
+                      ArgcList.insert(argptr+11);
+                      argptr+=12;
                       break;
 
                     case 'P':
-                      {
-                        if ((argptr+8 >= argc) || (!IsValidNumber(argv[argptr+1])) ||  (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+7])) || (!IsValidNumber(argv[argptr+8])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-') || (argv[argptr+5][0] == '-') || (argv[argptr+6][0] == '-')) {
-                          ExitFlag = 255;
-                          DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output> <binstart> <binend>" << endl);
-                          performCriticalExit();
-                        } else {
-                          ofstream output(argv[argptr+5]);
-                          ofstream binoutput(argv[argptr+6]);
-                          const double BinStart = atof(argv[argptr+7]);
-                          const double BinEnd = atof(argv[argptr+8]);
-
-                          std::vector<element *> elements;
-                          elements.push_back(periode->FindElement((const int) atoi(argv[argptr+1])));
-                          Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3]));
-                          CorrelationToPointMap *correlationmap = NULL;
-                          if (periodic)
-                            correlationmap  = PeriodicCorrelationToPoint(molecules, elements, Point, ranges);
-                          else
-                            correlationmap = CorrelationToPoint(molecules, elements, Point);
-                          OutputCorrelationToPoint(&output, correlationmap);
-                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
-                          OutputCorrelation ( &binoutput, binmap );
-                          output.close();
-                          binoutput.close();
-                          delete(Point);
-                          delete(binmap);
-                          delete(correlationmap);
-                          argptr+=9;
-                        }
-                      }
+                      ArgcList.insert(argptr-1);
+                      ArgcList.insert(argptr);
+                      ArgcList.insert(argptr+1);
+                      ArgcList.insert(argptr+2);
+                      ArgcList.insert(argptr+3);
+                      ArgcList.insert(argptr+4);
+                      ArgcList.insert(argptr+5);
+                      ArgcList.insert(argptr+6);
+                      ArgcList.insert(argptr+7);
+                      ArgcList.insert(argptr+8);
+                      ArgcList.insert(argptr+9);
+                      ArgcList.insert(argptr+10);
+                      ArgcList.insert(argptr+11);
+                      ArgcList.insert(argptr+12);
+                      ArgcList.insert(argptr+13);
+                      ArgcList.insert(argptr+14);
+                      argptr+=15;
                       break;
 
                     case 'S':
-                      {
-                        if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) {
-                          ExitFlag = 255;
-                          DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl);
-                          performCriticalExit();
-                        } else {
-                          ofstream output(argv[argptr+2]);
-                          ofstream binoutput(argv[argptr+3]);
-                          const double radius = 4.;
-                          const double BinWidth = atof(argv[argptr+4]);
-                          const double BinStart = atof(argv[argptr+5]);
-                          const double BinEnd = atof(argv[argptr+6]);
-                          double LCWidth = 20.;
-                          if (BinEnd > 0) {
-                            if (BinEnd > 2.*radius)
-                                LCWidth = BinEnd;
-                            else
-                              LCWidth = 2.*radius;
-                          }
-
-                          // get the boundary
-                          class molecule *Boundary = NULL;
-                          class Tesselation *TesselStruct = NULL;
-                          const LinkedCell *LCList = NULL;
-                          // find biggest molecule
-                          int counter  = 0;
-                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
-                            if ((Boundary == NULL) || (Boundary->getAtomCount() < (*BigFinder)->getAtomCount())) {
-                              Boundary = *BigFinder;
-                            }
-                            counter++;
-                          }
-                          bool *Actives = new bool[counter];
-                          counter = 0;
-                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
-                            Actives[counter++] = (*BigFinder)->ActiveFlag;
-                            (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
-                          }
-                          LCList = new LinkedCell(Boundary, LCWidth);
-                          std::vector<element *> elements;
-                          elements.push_back(periode->FindElement((const int) atoi(argv[argptr+1])));
-                          FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
-                          CorrelationToSurfaceMap *surfacemap = NULL;
-                          if (periodic)
-                            surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
-                          else
-                            surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
-                          OutputCorrelationToSurface(&output, surfacemap);
-                          // check whether radius was appropriate
-                          {
-                            double start; double end;
-                            GetMinMax( surfacemap, start, end);
-                            if (LCWidth < end)
-                              DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
-                          }
-                          BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
-                          OutputCorrelation ( &binoutput, binmap );
-                          output.close();
-                          binoutput.close();
-                          counter = 0;
-                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
-                            (*BigFinder)->ActiveFlag = Actives[counter++];
-                          delete[](Actives);
-                          delete(LCList);
-                          delete(TesselStruct);
-                          delete(binmap);
-                          delete(surfacemap);
-                          argptr+=7;
-                        }
-                      }
+                      ArgcList.insert(argptr-1);
+                      ArgcList.insert(argptr);
+                      ArgcList.insert(argptr+1);
+                      ArgcList.insert(argptr+2);
+                      ArgcList.insert(argptr+3);
+                      ArgcList.insert(argptr+4);
+                      ArgcList.insert(argptr+5);
+                      ArgcList.insert(argptr+6);
+                      ArgcList.insert(argptr+7);
+                      ArgcList.insert(argptr+8);
+                      ArgcList.insert(argptr+9);
+                      ArgcList.insert(argptr+10);
+                      ArgcList.insert(argptr+11);
+                      ArgcList.insert(argptr+12);
+                      ArgcList.insert(argptr+13);
+                      ArgcList.insert(argptr+14);
+                      argptr+=15;
                       break;
 
Index: src/moleculelist.cpp
===================================================================
--- src/moleculelist.cpp	(revision 1e6913b9968cc6beb553ca42434c08a099e00d98)
+++ src/moleculelist.cpp	(revision 58bbd3f2e470541a11fee67100edb3e8b589c40f)
@@ -799,5 +799,5 @@
       strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);
     }
-    DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << endl);
+    DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << ", id is " << molecules[i]->getId() << endl);
     for (molecule::iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) {
       DoLog(1) && (Log() << Verbose(1) << **iter << endl);
