Index: src/Fragmentation/Interfragmenter.cpp
===================================================================
--- src/Fragmentation/Interfragmenter.cpp	(revision 2fd88d1870ac3ece564aefb0904f1c5eec770f42)
+++ src/Fragmentation/Interfragmenter.cpp	(revision d410e25a69525e6b36defe22586e079cb795a160)
@@ -36,4 +36,6 @@
 
 #include "Interfragmenter.hpp"
+
+#include <algorithm>
 
 #include "CodePatterns/Assert.hpp"
@@ -98,23 +100,4 @@
 
   return candidates;
-}
-
-Interfragmenter::atomkeyset_t Interfragmenter::getCandidatesSpecificKeySetMap(
-    const candidates_t &_candidates,
-    const atomkeyset_t &_atomkeyset) const
-{
-  atomkeyset_t fragmentmap;
-  for (candidates_t::const_iterator candidateiter = _candidates.begin();
-      candidateiter != _candidates.end(); ++candidateiter) {
-    const atomId_t atomid = (*candidateiter)->getId();
-    atomkeyset_t::const_iterator iter = _atomkeyset.find(atomid);
-    ASSERT( iter != _atomkeyset.end(),
-        "Interfragmenter::getAtomSpecificKeySetMap() - could not find atom "
-        +toString(atomid)+" in lookup.");
-    fragmentmap.insert( std::make_pair( atomid, iter->second) );
-  }
-  LOG(4, "DEBUG: Copied part of lookup map contains " << fragmentmap.size() << " keys.");
-
-  return fragmentmap;
 }
 
@@ -166,4 +149,5 @@
 
 void Interfragmenter::operator()(
+    Graph &TotalGraph,
     const size_t MaxOrder,
     const double Rcut,
@@ -171,34 +155,44 @@
 {
   AtomFragmentsMap& atomfragments_container = AtomFragmentsMap::getInstance();
-  atomfragments_container.insert(TotalGraph);
   const atomkeyset_t &atomkeyset = atomfragments_container.getMap();
 
   Graph InterFragments;
-  int counter = TotalGraph.size();
+  int counter = atomkeyset.size();
 
   /// go through all fragments up to MaxOrder
   LOG(1, "INFO: Creating inter-fragments.");
-  for (Graph::const_iterator keysetiter = TotalGraph.begin();
-      keysetiter != TotalGraph.end(); ++keysetiter) {
-    const KeySet &keyset = keysetiter->first;
-    LOG(2, "DEBUG: Current keyset is " << keyset);
-    const AtomIdSet atoms(keyset);
-    const size_t atoms_size = atoms.getAtomIds().size();
-    if ((atoms_size > MaxOrder) || (atoms_size == 0))
-      continue;
-
-    // get neighboring atoms outside the current molecule
-    candidates_t candidates = getNeighborsOutsideMolecule(atoms, Rcut, treatment);
-
-    // create a lookup specific to this fragment
-    atomkeyset_t fragmentmap = getCandidatesSpecificKeySetMap(candidates, atomkeyset);
-
-    /// combine each remaining fragment with current fragment to a new fragment
-    /// if keyset is less (to prevent addding same inter-fragment twice)
-    combineFragments(MaxOrder, candidates, fragmentmap, keyset, InterFragments, counter);
+  for (atomkeyset_t::const_iterator atomiter = atomkeyset.begin();
+      atomiter != atomkeyset.end(); ++atomiter) {
+    const atomId_t &atomid = atomiter->first;
+    LOG(2, "DEBUG: Current atomid is " << atomid);
+
+    const AtomFragmentsMap::keysets_t &keysets = atomiter->second;
+    for (AtomFragmentsMap::keysets_t::const_iterator keyiter = keysets.begin();
+        keyiter != keysets.end(); ++keyiter) {
+      const KeySet &keyset = *keyiter;
+      const AtomIdSet atoms(keyset);
+      const size_t atoms_size = atoms.getAtomIds().size();
+      if ((atoms_size > MaxOrder) || (atoms_size == 0))
+        continue;
+
+      // get neighboring atoms outside the current molecule
+      candidates_t candidates = getNeighborsOutsideMolecule(atoms, Rcut, treatment);
+
+      // create a lookup specific to this fragment
+      std::vector<atomId_t> atomids(candidates.size());
+      std::transform(
+          candidates.begin(), candidates.end(),
+          atomids.begin(),
+          boost::bind(&atom::getId, _1));
+      atomkeyset_t fragmentmap = atomfragments_container.getMap(atomids, MaxOrder);
+
+      /// combine each remaining fragment with current fragment to a new fragment
+      /// if keyset is less (to prevent addding same inter-fragment twice)
+      combineFragments(MaxOrder, candidates, fragmentmap, keyset, InterFragments, counter);
+    }
   }
 
   /// eventually, add all new fragments to the Graph
-  counter = TotalGraph.size();
+  counter = atomkeyset.size();
   TotalGraph.InsertGraph(InterFragments, counter);
 }
@@ -215,26 +209,34 @@
 
   // go through each atom and find closest atom not in the same keyset
-  for (Graph::const_iterator keysetiter = TotalGraph.begin();
-      keysetiter != TotalGraph.end(); ++keysetiter) {
-    const KeySet &keyset = keysetiter->first;
-    LOG(2, "DEBUG: Current keyset is " << keyset);
-    const AtomIdSet atoms(keyset);
-
-    // get neighboring atoms outside the current molecule
-    const candidates_t candidates = getNeighborsOutsideMolecule(atoms, _upperbound, _treatment);
-    const Vector center = getAtomIdSetCenter(atoms);
-
-    for (candidates_t::const_iterator candidateiter = candidates.begin();
-        candidateiter != candidates.end(); ++candidateiter) {
-      atom const * const Walker = *candidateiter;
-      // go through each atom in set and pick minimal distance
-      for (AtomIdSet::const_iterator setiter = atoms.begin(); setiter != atoms.end(); ++setiter) {
-        const double distanceSquared = Walker->getPosition().DistanceSquared(center);
-        // pick the smallest compared to current Rcut if smaller
-        if (distanceSquared < Rcut) {
-          Rcut = distanceSquared;
-          ClosestPair.first = (*setiter)->getId();
-          ClosestPair.second = Walker->getId();
-          LOG(2, "DEBUG: Found new pair " << ClosestPair << " with distance " << sqrt(Rcut));
+  AtomFragmentsMap& atomfragments_container = AtomFragmentsMap::getInstance();
+  const atomkeyset_t &atomkeyset = atomfragments_container.getMap();
+  for (atomkeyset_t::const_iterator atomiter = atomkeyset.begin();
+      atomiter != atomkeyset.end(); ++atomiter) {
+    const atomId_t &atomid = atomiter->first;
+    LOG(2, "DEBUG: Current atomid is " << atomid);
+
+    const AtomFragmentsMap::keysets_t &keysets = atomiter->second;
+    for (AtomFragmentsMap::keysets_t::const_iterator keyiter = keysets.begin();
+        keyiter != keysets.end(); ++keyiter) {
+      const KeySet &keyset = *keyiter;
+      const AtomIdSet atoms(keyset);
+
+      // get neighboring atoms outside the current molecule
+      const candidates_t candidates = getNeighborsOutsideMolecule(atoms, _upperbound, _treatment);
+      const Vector center = getAtomIdSetCenter(atoms);
+
+      for (candidates_t::const_iterator candidateiter = candidates.begin();
+          candidateiter != candidates.end(); ++candidateiter) {
+        atom const * const Walker = *candidateiter;
+        // go through each atom in set and pick minimal distance
+        for (AtomIdSet::const_iterator setiter = atoms.begin(); setiter != atoms.end(); ++setiter) {
+          const double distanceSquared = Walker->getPosition().DistanceSquared(center);
+          // pick the smallest compared to current Rcut if smaller
+          if (distanceSquared < Rcut) {
+            Rcut = distanceSquared;
+            ClosestPair.first = (*setiter)->getId();
+            ClosestPair.second = Walker->getId();
+            LOG(2, "DEBUG: Found new pair " << ClosestPair << " with distance " << sqrt(Rcut));
+          }
         }
       }
Index: src/Fragmentation/Interfragmenter.hpp
===================================================================
--- src/Fragmentation/Interfragmenter.hpp	(revision 2fd88d1870ac3ece564aefb0904f1c5eec770f42)
+++ src/Fragmentation/Interfragmenter.hpp	(revision d410e25a69525e6b36defe22586e079cb795a160)
@@ -39,14 +39,7 @@
 {
 public:
-  /** Constructor for class Interfragmenter.
-   *
-   * \param _TotalGraph Graph with all fragments to interrelate
-   */
-  Interfragmenter(Graph &_TotalGraph) :
-    TotalGraph(_TotalGraph)
-  {}
-
   /** Adds interrelated fragments to TotalGraph up to \a MaxOrder and \a Rcut.
    *
+   * \param TotalGraph filled with additional inter-fragments on return
    * \param MaxOrder maximum order for fragments to interrelate
    * \param Rcut maximum distance to check for interrelatable fragments
@@ -54,4 +47,5 @@
    */
   void operator()(
+      Graph &TotalGraph,
       const size_t MaxOrder,
       const double Rcut,
@@ -90,14 +84,4 @@
       const enum HydrogenTreatment _treatment) const;
 
-  /** Helper function to return a fragment/KeySet map specific to all candidates.
-   *
-   * \param _candidates all neighboring atoms around keyset
-   * \param _atomkeyset map with all atoms and the KeySets they are contained in
-   * \return specific fragment map
-   */
-  atomkeyset_t getCandidatesSpecificKeySetMap(
-      const candidates_t &_candidates,
-      const atomkeyset_t &_atomkeyset) const;
-
   /** For a given set of candidates atoms in \a _candidates and a \a _keyset
    * we combine each fragment from either atom and place it into internal
@@ -118,7 +102,4 @@
       Graph &_InterFragments,
       int &_counter);
-
-private:
-  Graph &TotalGraph;
 };
 
