Index: src/Dynamics/LinearInterpolationBetweenSteps.hpp
===================================================================
--- src/Dynamics/LinearInterpolationBetweenSteps.hpp	(revision e355762f9447acb9c234eadd3df6adc314e5dee7)
+++ src/Dynamics/LinearInterpolationBetweenSteps.hpp	(revision eb33c4a913ab83436dbf30ab934797ec2d623036)
@@ -18,6 +18,8 @@
 #include "atom.hpp"
 #include "AtomSet.hpp"
+#include "CodePatterns/Assert.hpp"
 #include "CodePatterns/Info.hpp"
 #include "CodePatterns/Log.hpp"
+#include "CodePatterns/toString.hpp"
 #include "CodePatterns/Verbose.hpp"
 #include "Dynamics/MinimiseConstrainedPotential.hpp"
@@ -31,5 +33,4 @@
 public:
   LinearInterpolationBetweenSteps(AtomSetMixin<Set> &_atoms, unsigned int _MaxOuterStep) :
-    MDSteps(0),
     MaxOuterStep(_MaxOuterStep),
     IsAngstroem(true),
@@ -44,20 +45,15 @@
    * \param startstep stating initial configuration in molecule::Trajectories
    * \param endstep stating final configuration in molecule::Trajectories
-   * \param &prefix path and prefix
    * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential()
-   * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
    */
-  bool operator()(int startstep, int endstep, std::string prefix, bool MapByIdentity)
+  void operator()(int startstep, int endstep, bool MapByIdentity)
   {
     // TODO: rewrite permutationMaps using enumeration objects
-    molecule *mol = NULL;
-    bool status = true;
     int MaxSteps = MaxOuterStep;
-    MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::getPointer());
+
     // Get the Permutation Map by MinimiseConstrainedPotential
-    atom **PermutationMap = NULL;
-    atom *Sprinter = NULL;
+    std::map<atom*, atom *> PermutationMap;
     if (!MapByIdentity) {
-      std::map<atom *, atom*> PermutationMap;
+      LOG(1, "STATUS: Constructing atom mapping from start to end position.");
       molecule::atomSet atoms_list;
       copy(atoms.begin(), atoms.end(), atoms_list.begin());
@@ -65,12 +61,13 @@
       Minimiser(startstep, endstep, IsAngstroem);
     } else {
+      LOG(1, "STATUS: Using identity mapping.");
       // TODO: construction of enumeration goes here
-      PermutationMap = new atom *[atoms.size()];
       for(typename AtomSetMixin<Set>::const_iterator iter = atoms.begin(); iter != atoms.end();++iter){
-        PermutationMap[(*iter)->getNr()] = (*iter);
+        PermutationMap[(*iter)] = (*iter);
       }
     }
 
     // check whether we have sufficient space in Trajectories for each atom
+    LOG(1, "STATUS: Extending trajectories.");
     for(typename AtomSetMixin<Set>::iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
       (*iter)->ResizeTrajectory(MaxSteps);
@@ -83,37 +80,29 @@
 
     // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule
-    DoLog(1) && (Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl);
+    LOG(1, "STATUS: Filling intermediate " << MaxSteps << " steps." << endl);
     for (int step = 0; step <= MaxSteps; step++) {
-      mol = World::getInstance().createMolecule();
-      MoleculePerStep->insert(mol);
+      LOG(2, "INFO: Current step is " << step << "." << endl);
       for (typename AtomSetMixin<Set>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
-        // add to molecule list
-        Sprinter = mol->AddCopyAtom((*iter));
         // add to Trajectories
-        Vector temp = (*iter)->getPositionAtStep(startstep) + (PermutationMap[(*iter)->getNr()]->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep))*((double)step/(double)MaxSteps);
-        Sprinter->setPosition(temp);
+        ASSERT(PermutationMap.count((*iter)),
+            "LinearInterpolationBetweenSteps::operator() - atom "+toString(**iter)+" not found in PermutationMap.");
+        Vector temp = (*iter)->getPositionAtStep(startstep) + (PermutationMap[(*iter)]->getPositionAtStep(endstep) - (*iter)->getPositionAtStep(startstep))*((double)step/(double)MaxSteps);
+        (*iter)->setPositionAtStep(step,temp);
         (*iter)->setAtomicVelocityAtStep(step, zeroVec);
         (*iter)->setAtomicForceAtStep(step, zeroVec);
-        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
+        LOG(2, "INFO: Adding trajectory point for atom " << **iter << " at " << temp << ".");
       }
     }
-    MDSteps = MaxSteps+1;   // otherwise new Trajectories' points aren't stored on save&exit
 
-    // store the list to single step files
-    int *SortIndex = new int[atoms.size()];
-    for (int i=atoms.size(); i--; )
-      SortIndex[i] = i;
-
-    status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
-    delete[](SortIndex);
-
-    // free and return
-    delete[](PermutationMap);
-    delete(MoleculePerStep);
-    return status;
+//    // store the list to single step files
+//    int *SortIndex = new int[atoms.size()];
+//    for (int i=atoms.size(); i--; )
+//      SortIndex[i] = i;
+//
+//    status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
+//    delete[](SortIndex);
   };
 
 private:
-  unsigned int MDSteps;
   unsigned int MaxOuterStep;
   bool IsAngstroem;
