Index: src/Parser/TremoloParser.cpp
===================================================================
--- src/Parser/TremoloParser.cpp	(revision 1ee3b8d85bc3b82115508a188e0b73f52d7404db)
+++ src/Parser/TremoloParser.cpp	(revision 72d108d078550736c603bab52caa5d7586985f44)
@@ -34,4 +34,5 @@
 #include <vector>
 
+#include <boost/tokenizer.hpp>
 #include <iostream>
 #include <iomanip>
@@ -250,4 +251,5 @@
     usedFields.push_back(keyword);
   }
+  //DoLog(1) && (Log() << Verbose(1) << "INFO: " << usedFields << std::endl);
 }
 
@@ -267,47 +269,78 @@
   atomInfo = &additionalAtomData[newAtom->getId()];
   TremoloKey::atomDataKey currentField;
-  string word;
-  int oldId;
-  double tmp;
-
-  lineStream << line;
+  ConvertTo<double> toDouble;
+  ConvertTo<int> toInt;
+
+  // setup tokenizer, splitting up white-spaced entries
+  typedef boost::tokenizer<boost::char_separator<char> >
+      tokenizer;
+  boost::char_separator<char> whitespacesep(" \t");
+  tokenizer tokens(line, whitespacesep);
+  ASSERT(tokens.begin() != tokens.end(),
+      "TremoloParser::readAtomDataLine - empty string, need at least ' '!");
+  tokenizer::iterator tok_iter = tokens.begin();
+  // then associate each token to each file
   for (it = usedFields.begin(); it < usedFields.end(); it++) {
-    currentField = knownKeys[it->substr(0, it->find("="))];
+    const std::string keyName = it->substr(0, it->find("="));
+    currentField = knownKeys[keyName];
+    const string word = *tok_iter;
+    //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with remaining data " << word << std::endl);
     switch (currentField) {
       case TremoloKey::x :
         // for the moment, assume there are always three dimensions
         for (int i=0;i<NDIM;i++) {
-          lineStream >> tmp;
-          newAtom->set(i, tmp);
+          ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for x["+toString(i)+"]!");
+          //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
+          newAtom->set(i, toDouble(*tok_iter));
+          tok_iter++;
         }
         break;
       case TremoloKey::u :
         // for the moment, assume there are always three dimensions
-        lineStream >> newAtom->AtomicVelocity[0];
-        lineStream >> newAtom->AtomicVelocity[1];
-        lineStream >> newAtom->AtomicVelocity[2];
+        for (int i=0;i<NDIM;i++) {
+          ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for u["+toString(i)+"]!");
+          //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
+          newAtom->AtomicVelocity[i] = toDouble(*tok_iter);
+          tok_iter++;
+        }
         break;
       case TremoloKey::Type :
         char type[3];
-        lineStream >> type;
+        ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
+        //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
+        strncpy(type, (*tok_iter).c_str(), 3);
+        tok_iter++;
+        //type[1]='\0'; // cutoff after first char, correct for ATOM entries
         newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
         ASSERT(newAtom->getType(), "Type was not set for this atom");
         break;
       case TremoloKey::Id :
-        lineStream >> oldId;
-        atomIdMap[oldId] = newAtom->getId();
+        ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
+        //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
+        atomIdMap[toInt(*tok_iter)] = newAtom->getId();
+        tok_iter++;
         break;
       case TremoloKey::neighbors :
+        for (int i=0;i<atoi(it->substr(it->find("=") + 1, 1).c_str());i++) {
+          ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
+          //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
+          lineStream << *tok_iter << "\t";
+          tok_iter++;
+        }
         readNeighbors(&lineStream,
             atoi(it->substr(it->find("=") + 1, 1).c_str()), newAtom->getId());
         break;
       default :
-        lineStream >> word;
-        atomInfo->set(currentField, word);
-        break;
-    }
-  }
-  if (newmol != NULL)
+        ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!");
+        //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl);
+        atomInfo->set(currentField, *tok_iter);
+        tok_iter++;
+        break;
+    }
+  }
+  if (newmol != NULL) {
+    //DoLog(0) && (Log() << Verbose(0) << "New Atom: " << *newAtom << " with type " << newAtom->getType()->getName() << std::endl);
     newmol->AddAtom(newAtom);
+  }
 }
 
@@ -325,5 +358,8 @@
     // 0 is used to fill empty neighbor positions in the tremolo file.
     if (neighborId > 0) {
-//      std::cout << "Atom with global id " << atomId << " has neighbour with serial " << neighborId << std::endl;
+//      DoLog(1) && (Log() << Verbose(1)
+//          << "Atom with global id " << atomId
+//          << " has neighbour with serial " << neighborId
+//          << std::endl);
       additionalAtomData[atomId].neighbors.push_back(neighborId);
     }
@@ -366,8 +402,8 @@
         neighbor != currentInfo->second.neighbors.end(); neighbor++
       ) {
-//        std::cout << "Creating bond between ("
+//        DoLog(1) && (Log() << Verbose(1) << "Creating bond between ("
 //            << currentInfo->first
 //            << ") and ("
-//            << atomIdMap[*neighbor] << "|" << *neighbor << ")" << std::endl;
+//            << atomIdMap[*neighbor] << "|" << *neighbor << ")" << std::endl);
         World::getInstance().getAtom(AtomById(currentInfo->first))
             ->addBond(World::getInstance().getAtom(AtomById(atomIdMap[*neighbor])));
