Index: trunk/FACT++/src/EventBuilderWrapper.h
===================================================================
--- trunk/FACT++/src/EventBuilderWrapper.h	(revision 12488)
+++ trunk/FACT++/src/EventBuilderWrapper.h	(revision 12489)
@@ -525,13 +525,14 @@
 
         map<uint32_t,FAD::RunDescription>::iterator it = fExpectedRuns.begin();
-        while (1)
+        while (it!=fExpectedRuns.end())
         {
             if (it->first<runid)
             {
                 ostringstream str;
-                str << "runOpen - Missed run " << runid << "." << endl;
+                str << "runOpen - Missed run " << it->first << "." << endl;
                 fMsg.Info(str);
 
-                fExpectedRuns.erase(it);
+                fExpectedRuns.erase(it++);
+                continue;
             }
             if (it->first==runid)
@@ -957,13 +958,14 @@
         // This function is called even when writing is switched off
         set<uint32_t>::iterator it = fIsRunStarted.begin();
-        while (1)
+        while (it!=fIsRunStarted.end())
         {
             if (*it<runnr)
             {
                 ostringstream str;
-                str << "gotNewRun - Missed run " << runnr << "." << endl;
+                str << "gotNewRun - Missed run " << *it << "." << endl;
                 fMsg.Info(str);
 
-                fIsRunStarted.erase(it);
+                fIsRunStarted.erase(it++);
+                continue;
             }
             if (*it==runnr)
@@ -1384,6 +1386,9 @@
     {
         const uint16_t *ptr = reinterpret_cast<uint16_t*>(buf);
-
         EventBuilderWrapper::This->debugHead(socket, FAD::EventHeader(ptr));
+
+        // const FAD::EventHeader &h = *reinterpret_cast<FAD::EventHeader*>(buf);
+        // EventBuilderWrapper::This->debugHead(socket, h);
+
     }
 
