Index: src/Fragmentation/KeySetsContainer.cpp
===================================================================
--- src/Fragmentation/KeySetsContainer.cpp	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
+++ src/Fragmentation/KeySetsContainer.cpp	(revision 8b58ac216014d5bef5ecc26c850653adf4ddd5aa)
@@ -37,4 +37,7 @@
 #include <fstream>
 #include <sstream>
+
+#include <boost/lexical_cast.hpp>
+#include <boost/tokenizer.hpp>
 
 #include "CodePatterns/Log.hpp"
@@ -72,14 +75,16 @@
  * \return parsing succesful
  */
-bool KeySetsContainer::ParseKeySets(const std::string name, const IntVector ACounter, const int FCounter) {
+bool KeySetsContainer::ParseKeySets(const std::string path, const std::string name, const int FCounter) {
   ifstream input;
-  char *FragmentNumber = NULL;
+  //char *FragmentNumber = NULL;
   stringstream file;
   char filename[1023];
 
   FragmentCounter = FCounter;
-  LOG(0, "Parsing key sets.");
   KeySets.resize(FragmentCounter);
-  file << name << FRAGMENTPREFIX << KEYSETFILE;
+  AtomCounter.resize(FragmentCounter);
+
+  // open file
+  file << path << "/" << name;
   input.open(file.str().c_str(), ios::in);
   if (input.fail()) {
@@ -88,23 +93,29 @@
   }
 
-  AtomCounter.resize(FragmentCounter);
+  // parse each line, i.e. get the index set per fragment
+  LOG(0, "Parsing key sets.");
   for(int i=0;(i<FragmentCounter) && (!input.eof());i++) {
-    stringstream line;
-    AtomCounter[i] = ACounter[i];
-    // parse the values
-    KeySets[i].resize(AtomCounter[i]);
-    for(int j=AtomCounter[i];j--;)
-      KeySets[i][j] = -1;
-    FragmentNumber = FixedDigitNumber(FragmentCounter, i);
-    //std::stringstream output;
-    //output << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:";
-    delete[](FragmentNumber);
     input.getline(filename, 1023);
-    line.str(filename);
-    for(int j=0;(j<AtomCounter[i]) && (!line.eof());j++) {
-      line >> KeySets[i][j];
-      //output << " " << KeySets[i][j];
+    string line(filename);
+//    LOG(2, "DEBUG: line is " << line << ".");
+    std::stringstream set_output;
+    typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
+    boost::char_separator<char> sep(" \t");
+    tokenizer tok(line, sep);
+    for(tokenizer::iterator beg=tok.begin();
+        beg != tok.end();++beg){
+      const int tempvalue = boost::lexical_cast<int>(*beg);
+      KeySets[i].push_back(tempvalue);
+//      set_output << " " << KeySets[i].back();
     }
-    //LOG(0, output.str());
+//    LOG(2, "DEBUG: Scanned keys are '" << set_output.str() << "'.");
+    AtomCounter[i] = KeySets[i].size();
+//    {
+//      std::stringstream output;
+//      FragmentNumber = FixedDigitNumber(FragmentCounter, i);
+//      output << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:" << set_output.str();
+//      delete[](FragmentNumber);
+//      LOG(0, output.str());
+//    }
   }
   input.close();
Index: src/Fragmentation/KeySetsContainer.hpp
===================================================================
--- src/Fragmentation/KeySetsContainer.hpp	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
+++ src/Fragmentation/KeySetsContainer.hpp	(revision 8b58ac216014d5bef5ecc26c850653adf4ddd5aa)
@@ -35,5 +35,5 @@
   ~KeySetsContainer();
 
-  bool ParseKeySets(const std::string name, const std::vector<int> ACounter, const int FCounter);
+  bool ParseKeySets(const std::string path, const std::string name, const int FCounter);
   bool ParseManyBodyTerms();
   bool Contains(const int GreaterSet, const int SmallerSet);
Index: src/Fragmentation/analyzer.cpp
===================================================================
--- src/Fragmentation/analyzer.cpp	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
+++ src/Fragmentation/analyzer.cpp	(revision 8b58ac216014d5bef5ecc26c850653adf4ddd5aa)
@@ -182,5 +182,9 @@
 
   // ---------- Parse the KeySets into an array ---------------
-  if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
+  {
+    std::stringstream filename;
+    filename << FRAGMENTPREFIX << KEYSETFILE;
+    if (!KeySet.ParseKeySets(argv[1], filename.str(), Force.MatrixCounter)) return 1;
+  }
   if (!KeySet.ParseManyBodyTerms()) return 1;
 
Index: src/Fragmentation/joiner.cpp
===================================================================
--- src/Fragmentation/joiner.cpp	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
+++ src/Fragmentation/joiner.cpp	(revision 8b58ac216014d5bef5ecc26c850653adf4ddd5aa)
@@ -147,5 +147,9 @@
 
   // ---------- Parse the KeySets into an array ---------------
-  if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
+  {
+    std::stringstream filename;
+    filename << FRAGMENTPREFIX << KEYSETFILE;
+    if (!KeySet.ParseKeySets(argv[1], filename.str(), Force.MatrixCounter)) return 1;
+  }
 
   if (!KeySet.ParseManyBodyTerms()) return 1;
