Index: src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp
===================================================================
--- src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp	(revision c00d359f173d2e16a9424a03c781f723da85fa93)
+++ src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp	(revision 66fd499538327fa9d63d45ec481787c8650b9509)
@@ -28,4 +28,5 @@
 #include "World.hpp"
 
+#include "Descriptors/MoleculeIdDescriptor.hpp"
 #include "Parser/MpqcParser.hpp"
 #include "Parser/PcpParser.hpp"
@@ -35,4 +36,5 @@
 #include "Parser/FormatParserStorage.hpp"
 
+#include <algorithm>
 #include <iostream>
 #include <string>
@@ -47,11 +49,16 @@
 /** =========== define the function ====================== */
 Action::state_ptr MoleculeFillVoidWithMoleculeAction::performCall() {
-
   // obtain information
   getParametersfromValueStorage();
 
-  DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << params.lengths[0] << "," << params.lengths[1] << "," << params.lengths[2] << "), distances (" << params.distances[0] << "," << params.distances[1] << "," << params.distances[2] << "), DoRotate " << params.DoRotate << "." << endl);
+  if (!boost::filesystem::exists(params.fillername)) {
+    DoeLog(1) && (eLog() << Verbose(1) << "File with filler molecule " << params.fillername << " does not exist!" << endl);
+    return Action::failure;
+  }
+
+  DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << params.lengths[0] << "," << params.lengths[1] << "," << params.lengths[2] << "), distances (" << params.distances[0] << "," << params.distances[1] << "," << params.distances[2] << "), MinDistance " << params.MinDistance << ", DoRotate " << params.DoRotate << "." << endl);
   // construct water molecule
-  molecule *filler = World::getInstance().createMolecule();
+  std::vector<molecule *> presentmolecules = World::getInstance().getAllMolecules();
+//  DoLog(0) && (Log() << Verbose(0) << presentmolecules.size() << " molecules initially are present." << std::endl);
   std::string FilenameSuffix = params.fillername.string().substr(params.fillername.string().find_last_of('.')+1, params.fillername.string().length());
   ifstream input;
@@ -92,6 +99,10 @@
       break;
   }
-  World::MoleculeIterator iter = World::getInstance().getMoleculeIter();
-  for (; iter != World::getInstance().moleculeEnd(); ++iter)
+
+  // search the filler molecule that has been just parsed
+  molecule *filler = NULL;
+  for (World::MoleculeIterator iter = World::getInstance().getMoleculeIter();
+      iter != World::getInstance().moleculeEnd();
+      ++iter)
     filler = *iter; // get last molecule
   filler->SetNameFromFilename(params.fillername.string().c_str());
@@ -102,29 +113,64 @@
   for (int i=0;i<NDIM;i++)
     distance[i] = params.distances[i];
-  FillVoidWithMolecule(filler, *(World::getInstance().getConfig()), distance, params.lengths[0], params.lengths[1], params.lengths[2], params.DoRotate);
+  FillVoidWithMolecule(filler, *(World::getInstance().getConfig()), distance, params.lengths[0], params.lengths[1], params.lengths[2], params.MinDistance, params.DoRotate);
 
-  return Action::success;
+  // generate list of newly created molecules
+  // (we can in general remove more quickly from a list than a vector)
+  std::vector<molecule *> fillermolecules = World::getInstance().getAllMolecules();
+//  DoLog(0) && (Log() << Verbose(0) << fillermolecules.size() << " molecules are present." << std::endl);
+  std::list<molecule *> fillermolecules_list;
+  std::copy( fillermolecules.begin(),  fillermolecules.end(), std::back_inserter( fillermolecules_list ));
+//  DoLog(0) && (Log() << Verbose(0) << fillermolecules_list.size() << " molecules have been copied." << std::endl);
+  for (std::vector<molecule *>::const_iterator iter = presentmolecules.begin();
+      iter != presentmolecules.end();
+      ++iter) {
+    fillermolecules_list.remove(*iter);
+  }
+//  DoLog(0) && (Log() << Verbose(0) << fillermolecules_list.size() << " molecules left after removal." << std::endl);
+  fillermolecules.clear();
+  std::copy(fillermolecules_list.begin(), fillermolecules_list.end(), std::back_inserter( fillermolecules ));
+
+//  DoLog(0) && (Log() << Verbose(0) << fillermolecules.size() << " molecules have been inserted." << std::endl);
+
+  return Action::state_ptr(new MoleculeFillVoidWithMoleculeState(fillermolecules,params));
 }
 
 Action::state_ptr MoleculeFillVoidWithMoleculeAction::performUndo(Action::state_ptr _state) {
-//  MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get());
+  MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get());
 
-//  string newName = state->mol->getName();
-//  state->mol->setName(state->lastName);
+  MoleculeListClass *MolList = World::getInstance().getMolecules();
 
-  return Action::failure;
+  BOOST_FOREACH(molecule *_mol, state->fillermolecules) {
+    MolList->erase(_mol);
+    if ((_mol != NULL) && (!(World::getInstance().getAllMolecules(MoleculeById(_mol->getId()))).empty())) {
+      for(molecule::iterator iter = _mol->begin();
+          !_mol->empty();
+          iter = _mol->begin()) {
+        atom *Walker = *iter;
+        _mol->erase(iter);
+        World::getInstance().destroyAtom(Walker);
+      }
+      World::getInstance().destroyMolecule(_mol);
+    }
+  }
+
+  // as molecules and atoms from state are removed, we have to create a new one
+  std::vector<molecule *> fillermolecules;
+  return Action::state_ptr(new MoleculeFillVoidWithMoleculeState(fillermolecules,state->params));
 }
 
 Action::state_ptr MoleculeFillVoidWithMoleculeAction::performRedo(Action::state_ptr _state){
-  // Undo and redo have to do the same for this action
-  return performUndo(_state);
+  //MoleculeFillVoidWithMoleculeState *state = assert_cast<MoleculeFillVoidWithMoleculeState*>(_state.get());
+
+  return Action::failure;
+  //return Action::state_ptr(_state);
 }
 
 bool MoleculeFillVoidWithMoleculeAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool MoleculeFillVoidWithMoleculeAction::shouldUndo() {
-  return false;
+  return true;
 }
 /** =========== end of function ====================== */
Index: src/Actions/MoleculeAction/FillVoidWithMoleculeAction.def
===================================================================
--- src/Actions/MoleculeAction/FillVoidWithMoleculeAction.def	(revision c00d359f173d2e16a9424a03c781f723da85fa93)
+++ src/Actions/MoleculeAction/FillVoidWithMoleculeAction.def	(revision 66fd499538327fa9d63d45ec481787c8650b9509)
@@ -13,12 +13,12 @@
 // ValueStorage by the token "Z" -> first column: int, Z, "Z"
 // "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
-#define paramtypes (boost::filesystem::path)(Vector)(Vector)(bool)
-#define paramtokens ("fill-void")("distances")("lengths")("DoRotate")
-#define paramdescriptions ("name of xyz file of filler molecule")("list of three of distances in space, one for each axis direction")("list of three of lengths in space, one for each axis direction")("whether to rotate or not")
-#undef paramdefaults
-#define paramreferences (fillername)(distances)(lengths)(DoRotate)
+#define paramtypes (boost::filesystem::path)(Vector)(Vector)(double)(bool)
+#define paramtokens ("fill-void")("distances")("lengths")("MinDistance")("DoRotate")
+#define paramdescriptions ("name of xyz file of filler molecule")("list of three of distances in space, one for each axis direction")("list of three of lengths in space, one for each axis direction")("minimum distance to boundary")("whether to rotate or not")
+#define paramdefaults (NODEFAULT)(NODEFAULT)(NODEFAULT)("0.")("0")
+#define paramreferences (fillername)(distances)(lengths)(MinDistance)(DoRotate)
 
-#undef statetypes
-#undef statereferences
+#define statetypes (std::vector<molecule *>)
+#define statereferences (fillermolecules)
 
 // some defines for all the names, you may use ACTION, STATE and PARAMS
