Index: src/Fragmentation/Fragmentation.cpp
===================================================================
--- src/Fragmentation/Fragmentation.cpp	(revision 0331ee67517aeb31a2ec94499de1284c95285f83)
+++ src/Fragmentation/Fragmentation.cpp	(revision 3214709df996960491949bad946226a294270b56)
@@ -33,4 +33,6 @@
 #endif
 
+#include <boost/bimap.hpp>
+
 #include "CodePatterns/MemDebug.hpp"
 
@@ -39,4 +41,5 @@
 #include "CodePatterns/Assert.hpp"
 #include "CodePatterns/Info.hpp"
+#include "CodePatterns/IteratorAdaptors.hpp"
 #include "CodePatterns/Log.hpp"
 
@@ -127,7 +130,25 @@
   // ===== 1. Check whether bond structure is same as stored in files ====
 
+  // create a lookup global <-> local id for atomic ids valid in World and in molecule
+  Global_local_bimap_t Global_local_bimap;
+  for (std::vector<local_t>::const_iterator iter = atomids.begin();
+      iter != atomids.end();
+      ++iter) {
+    const atom * _atom = mol->FindAtom(*iter);
+    ASSERT( _atom != NULL,
+        "Fragmentation::FragmentMolecule() - could not find atom "+toString(*iter)+".");
+    Global_local_bimap.insert(
+        idpair_t(
+            (global_t)(_atom->getId()), (local_t)(*iter)
+            )
+        );
+  }
+
   // === compare it with adjacency file ===
   {
-    const std::vector<atomId_t> globalids = getGlobalIdsFromLocalIds(*mol, atomids);
+    const std::vector<atomId_t> globalids(
+        MapKeyConstIterator<Global_local_bimap_t::left_const_iterator>(Global_local_bimap.left.begin()),
+        MapKeyConstIterator<Global_local_bimap_t::left_const_iterator>(Global_local_bimap.left.end())
+        );
     AdjacencyList WorldAdjacency(globalids);
     FragmentationToDo = FragmentationToDo && (FileChecker > WorldAdjacency);
@@ -143,5 +164,5 @@
 
   // ===== 4. check globally whether there's something to do actually (first adaptivity check)
-  FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(atomids, prefix);
+  FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(atomids, prefix, Global_local_bimap);
 
   // =================================== Begin of FRAGMENTATION ===============================
@@ -398,5 +419,6 @@
  * \return true - file writable, false - not writable
  */
-bool Fragmentation::StoreOrderAtSiteFile(const std::string &path)
+bool Fragmentation::StoreOrderAtSiteFile(
+    const std::string &path)
 {
   string line;
@@ -404,9 +426,13 @@
 
   line = path + ORDERATSITEFILE;
-  file.open(line.c_str());
+  file.open(line.c_str(), std::ofstream::out | std::ofstream::app);
   std::stringstream output;
   output << "INFO: Writing OrderAtSite " << ORDERATSITEFILE << " ... ";
   if (file.good()) {
-    for_each(mol->begin(),mol->end(),bind2nd(mem_fun(&atom::OutputOrder), &file));
+    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
+      file << (*iter)->getId()
+          << "\t" << (int)(*iter)->AdaptiveOrder
+          << "\t" << (int)(*iter)->MaxOrder << std::endl;
+    }
     file.close();
     output << "done.";
@@ -423,9 +449,13 @@
  * Atoms not present in the file get "0".
  * \param atomids atoms to fragment, used in AtomMask
- * \param &path path to file ORDERATSITEFILEe
+ * \param &path path to file ORDERATSITEFILE
+ * \param global_local_bimap translate global to local id
  * \return true - file found and scanned, false - file not found
  * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two
  */
-bool Fragmentation::ParseOrderAtSiteFromFile(const std::vector<atomId_t> &atomids, const std::string &path)
+bool Fragmentation::ParseOrderAtSiteFromFile(
+    const std::vector<atomId_t> &atomids,
+    const std::string &path,
+    const Global_local_bimap_t &global_local_bimap)
 {
 //  Info FunctionInfo(__func__);
@@ -435,5 +465,5 @@
   AtomMask_t MaxArray(atomids);
   bool status;
-  int AtomNr, value;
+  int AtomNr, ordervalue, maxvalue;
   string line;
   ifstream file;
@@ -445,10 +475,16 @@
       AtomNr = -1;
       file >> AtomNr;
+      file >> ordervalue;
+      file >> maxvalue;
       if (AtomNr != -1) {   // test whether we really parsed something (this is necessary, otherwise last atom is set twice and to 0 on second time)
-        file >> value;
-        OrderArray[AtomNr] = value;
-        file >> value;
-        MaxArray.setValue(AtomNr, (bool)value);
-        //LOG(2, "AtomNr " << AtomNr << " with order " << (int)OrderArray[AtomNr] << " and max order set to " << (int)MaxArray[AtomNr] << ".");
+        // parsed id is global, must be translated to local id
+        Global_local_bimap_t::left_const_iterator iter = global_local_bimap.left.find(AtomNr);
+        // skip global ids we don't know about, must be in other molecule
+        if (iter != global_local_bimap.left.end()) {
+          const int LocalId = iter->second;
+          OrderArray[LocalId] = ordervalue;
+          MaxArray.setValue(LocalId, (bool)maxvalue);
+          //LOG(2, "AtomNr " << LocalId << " with order " << (int)OrderArray[LocalId] << " and max order set to " << (int)MaxArray[LocalId] << ".");
+        }
       }
     }
Index: src/Fragmentation/Fragmentation.hpp
===================================================================
--- src/Fragmentation/Fragmentation.hpp	(revision 0331ee67517aeb31a2ec94499de1284c95285f83)
+++ src/Fragmentation/Fragmentation.hpp	(revision 3214709df996960491949bad946226a294270b56)
@@ -25,4 +25,6 @@
 #include <vector>
 
+#include <boost/bimap.hpp>
+
 class atom;
 class AtomMask_t;
@@ -33,4 +35,9 @@
 class Fragmentation
 {
+  // some typedefs for intermediat global id <-> local id bimap
+  typedef atomId_t global_t;
+  typedef atomId_t local_t;
+  typedef boost::bimap< global_t, local_t > Global_local_bimap_t;
+  typedef Global_local_bimap_t::value_type idpair_t;
 public:
   Fragmentation(
@@ -54,5 +61,5 @@
   bool CheckOrderAtSite(AtomMask_t &AtomMask, const Graph &GlobalKeySetList, int Order, const std::string &path, bool LoopDoneAlready);
   bool StoreOrderAtSiteFile(const std::string &path);
-  bool ParseOrderAtSiteFromFile(const std::vector<atomId_t> &atomids, const std::string &path);
+  bool ParseOrderAtSiteFromFile(const std::vector<atomId_t> &atomids, const std::string &path, const Global_local_bimap_t &global_local_bimap);
 
   // storing fragments
