Index: src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp
===================================================================
--- src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp	(revision 967b3cc1d5bcc09f04bc4e2f99bb7620de669545)
+++ src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp	(revision 7a51bed0ac43de73ef69542c07ec8d25a2b6d4cc)
@@ -23,16 +23,12 @@
 #include "bondgraph.hpp"
 #include "boundary.hpp"
+#include "CodePatterns/Verbose.hpp"
 #include "config.hpp"
+#include "Descriptors/MoleculeIdDescriptor.hpp"
+#include "Descriptors/MoleculeOrderDescriptor.hpp"
 #include "molecule.hpp"
-#include "CodePatterns/Verbose.hpp"
+#include "Parser/FormatParserStorage.hpp"
 #include "World.hpp"
 
-#include "Descriptors/MoleculeIdDescriptor.hpp"
-#include "Parser/MpqcParser.hpp"
-#include "Parser/PcpParser.hpp"
-#include "Parser/PdbParser.hpp"
-#include "Parser/TremoloParser.hpp"
-#include "Parser/XyzParser.hpp"
-#include "Parser/FormatParserStorage.hpp"
 
 #include <algorithm>
@@ -70,46 +66,10 @@
   ifstream input;
   input.open(params.fillername.string().c_str());
-  switch (FormatParserStorage::getInstance().getTypeFromSuffix(FilenameSuffix)) {
-    case mpqc:
-      {
-        MpqcParser mpqcparser;
-        mpqcparser.load(&input);
-        break;
-      }
-    case pcp:
-      {
-        PcpParser pcpparser;
-        pcpparser.load(&input);
-        break;
-      }
-    case pdb:
-      {
-        PdbParser pdbparser;
-        pdbparser.load(&input);
-        break;
-      }
-    case tremolo:
-      {
-        TremoloParser tremoloparser;
-        tremoloparser.load(&input);
-        break;
-      }
-    case xyz:
-      {
-        XyzParser xyzparser;
-        xyzparser.load(&input);
-        break;
-      }
-    default:
-      DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << params.fillername << "." << endl);
-      break;
-  }
+  ParserTypes type = FormatParserStorage::getInstance().getTypeFromSuffix(FilenameSuffix);
+  FormatParser &parser = FormatParserStorage::getInstance().get(type);
+  parser.load(&input);
 
   // 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
+  molecule *filler = World::getInstance().getMolecule(MoleculeByOrder(-1)); // get last molecule
   filler->SetNameFromFilename(params.fillername.string().c_str());
   World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
Index: src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
===================================================================
--- src/Actions/MoleculeAction/FillWithMoleculeAction.cpp	(revision 967b3cc1d5bcc09f04bc4e2f99bb7620de669545)
+++ src/Actions/MoleculeAction/FillWithMoleculeAction.cpp	(revision 7a51bed0ac43de73ef69542c07ec8d25a2b6d4cc)
@@ -23,7 +23,10 @@
 #include "bondgraph.hpp"
 #include "boundary.hpp"
+#include "CodePatterns/Verbose.hpp"
 #include "config.hpp"
+#include "Descriptors/MoleculeIdDescriptor.hpp"
+#include "Descriptors/MoleculeOrderDescriptor.hpp"
 #include "molecule.hpp"
-#include "CodePatterns/Verbose.hpp"
+#include "Parser/FormatParserStorage.hpp"
 #include "World.hpp"
 
@@ -53,32 +56,25 @@
       << ", DoRotate " << params.DoRotate << "." << endl);
   // construct water molecule
-  molecule *filler = World::getInstance().createMolecule();
-  if (!filler->AddXYZFile(params.fillername.string())) {
-    DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << params.fillername << "." << endl);
-  }
+  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;
+  input.open(params.fillername.string().c_str());
+  ParserTypes type = FormatParserStorage::getInstance().getTypeFromSuffix(FilenameSuffix);
+  FormatParser &parser = FormatParserStorage::getInstance().get(type);
+  parser.load(&input);
+
+  // search the filler molecule that has been just parsed
+  molecule *filler = World::getInstance().getMolecule(MoleculeByOrder(-1)); // get last molecule
   filler->SetNameFromFilename(params.fillername.string().c_str());
-  molecule *Filling = NULL;
-//    atom *first = NULL, *second = NULL, *third = NULL;
-//    first = World::getInstance().createAtom();
-//    first->type = World::getInstance().getPeriode()->FindElement(1);
-//    first->x = Vector(0.441, -0.143, 0.);
-//    filler->AddAtom(first);
-//    second = World::getInstance().createAtom();
-//    second->type = World::getInstance().getPeriode()->FindElement(1);
-//    second->x = Vector(-0.464, 1.137, 0.0);
-//    filler->AddAtom(second);
-//    third = World::getInstance().createAtom();
-//    third->type = World::getInstance().getPeriode()->FindElement(8);
-//    third->x = Vector(-0.464, 0.177, 0.);
-//    filler->AddAtom(third);
-//    filler->AddBond(first, third, 1);
-//    filler->AddBond(second, third, 1);
   World::getInstance().getConfig()->BG->ConstructBondGraph(filler);
-//    filler->SetNameFromFilename("water");
+  // TODO: Remove the erasure of molecule when saving does not depend on them anymore.
+  World::getInstance().getMolecules()->erase(filler); // remove it, Parser adds it automatically
+
   // call routine
   double distance[NDIM];
   for (int i=0;i<NDIM;i++)
     distance[i] = params.distances[i];
-  Filling = FillBoxWithMolecule(
+  FillBoxWithMolecule(
       World::getInstance().getMolecules(),
       filler, *(World::getInstance().getConfig()),
@@ -89,8 +85,4 @@
       params.RandMoleculeDisplacement,
       params.DoRotate);
-  if (Filling != NULL) {
-    Filling->ActiveFlag = false;
-    World::getInstance().getMolecules()->insert(Filling);
-  }
   for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) {
     atom *Walker = *iter;
@@ -100,27 +92,62 @@
   World::getInstance().destroyMolecule(filler);
 
-  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 MoleculeFillWithMoleculeState(fillermolecules,params));
 }
 
 Action::state_ptr MoleculeFillWithMoleculeAction::performUndo(Action::state_ptr _state) {
-//  MoleculeFillWithMoleculeState *state = assert_cast<MoleculeFillWithMoleculeState*>(_state.get());
+  MoleculeFillWithMoleculeState *state = assert_cast<MoleculeFillWithMoleculeState*>(_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 MoleculeFillWithMoleculeState(fillermolecules,state->params));
 }
 
 Action::state_ptr MoleculeFillWithMoleculeAction::performRedo(Action::state_ptr _state){
-  // Undo and redo have to do the same for this action
-  return performUndo(_state);
+  //MoleculeFillWithMoleculeState *state = assert_cast<MoleculeFillWithMoleculeState*>(_state.get());
+
+  return Action::failure;
+  //return Action::state_ptr(_state);
 }
 
 bool MoleculeFillWithMoleculeAction::canUndo() {
-  return false;
+  return true;
 }
 
 bool MoleculeFillWithMoleculeAction::shouldUndo() {
-  return false;
+  return true;
 }
 /** =========== end of function ====================== */
Index: src/Actions/MoleculeAction/FillWithMoleculeAction.def
===================================================================
--- src/Actions/MoleculeAction/FillWithMoleculeAction.def	(revision 967b3cc1d5bcc09f04bc4e2f99bb7620de669545)
+++ src/Actions/MoleculeAction/FillWithMoleculeAction.def	(revision 7a51bed0ac43de73ef69542c07ec8d25a2b6d4cc)
@@ -19,6 +19,6 @@
 #define paramreferences (fillername)(distances)(boundary)(RandAtomDisplacement)(RandMoleculeDisplacement)(MaxDistance)(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
