Index: fact/FADctrl/FAD.cc
===================================================================
--- fact/FADctrl/FAD.cc	(revision 10290)
+++ fact/FADctrl/FAD.cc	(revision 10291)
@@ -753,5 +753,5 @@
 void FAD::cmd_stop() {
 
-  static char Stop[] = "stop";
+  static char Stop[] = "stop\n";
 
   if (Mode == idle) {
@@ -767,5 +767,5 @@
   if (Mode == datarun) {  
 	// Inform event thread to stop run in case datarun active
-	if (write(Pipe[1], Stop, strlen(Stop)+1) == -1) {
+	if (write(Pipe[1], Stop, strlen(Stop)) == -1) {
 	  Message(ERROR, "write() to Pipe[1] failed in FAD::cmd_cancel() (%s)", strerror(errno));
 	}
@@ -896,4 +896,8 @@
   // Update loop
   while (!ExitRequest) {
+	// Removed processed data from IDString
+	size_t LastLF = IDString.find_last_of("\n");
+	if (LastLF != string::npos) IDString = IDString.substr(LastLF+1);
+
     // Wait for data from TCP/IP reading threads
     if ((Ret=read(Pipe[0], Buffer, sizeof(Buffer))) == -1) Message(FATAL, "read() from Pipe[0] failed in FAD::EventThread() (%s)", strerror(errno));
@@ -901,6 +905,6 @@
 	// Check if pipe closed
 	if (Ret == 0) break;
-	
-	IDString = string(Buffer, Ret);
+
+	IDString.append(string(Buffer, Ret));
 
 	// If amplitude calibration mode, check if board finished procedure
@@ -939,12 +943,12 @@
 
 	  if (lseek(Datafile, 0, SEEK_SET) == -1) {
-	    PrintMessage("Error: Could not rewind file to write updated run header (%s)\n", strerror(errno));
+	    Message(ERROR, "Could not rewind file to write updated run header (%s)", strerror(errno));
 	  }
 	  else if (write(Datafile, RHeader, sizeof(RunHeader)) != sizeof(RunHeader)) {
-		PrintMessage("Error: Could not write updated run header (%s)\n", strerror(errno));
+		Message(ERROR, "Could not write updated run header (%s)", strerror(errno));
 	  }
 
 	  // Close data file and terminate run
-	  if(close(Datafile) == -1) PrintMessage("Error: Could not close data file (%s)\n", strerror(errno));
+	  if(close(Datafile) == -1) Message(ERROR, "Could not close data file (%s)", strerror(errno));
 	  else PrintMessage("Data file closed (size %.1f MByte).\n", FileSize/1024.0/1024);
 
Index: fact/FADctrl/FADBoard.cc
===================================================================
--- fact/FADctrl/FADBoard.cc	(revision 10290)
+++ fact/FADctrl/FADBoard.cc	(revision 10291)
@@ -84,4 +84,14 @@
   }
 
+  // Delete condition variable 
+  if ((Ret = pthread_cond_destroy(&CondVar)) != 0) {
+	m->Message(m->ERROR, "pthread_cond_destroy() failed for %s in ~FADBoard (%s)", Name, strerror(Ret));
+  }
+
+  // Delete mutex  
+  if ((Ret = pthread_mutex_destroy(&Mutex)) != 0) {
+	m->Message(m->ERROR, "pthread_mutex_destroy() failed for %s in ~FADBoard (%s)", Name, strerror(Ret));
+  }
+
   delete DIM_Name;
   delete DIM_Status;
@@ -93,14 +103,4 @@
   delete DIM_ROI;  
   delete[] Name;
-
-  // Delete condition variable 
-  if ((Ret = pthread_cond_destroy(&CondVar)) != 0) {
-	m->Message(m->ERROR, "pthread_cond_destroy() failed in ~FADBoard (%s)", strerror(Ret));
-  }
-
-  // Delete mutex  
-  if ((Ret = pthread_mutex_destroy(&Mutex)) != 0) {
-	m->Message(m->ERROR, "pthread_mutex_destroy() failed in ~FADBoard (%s)", strerror(Ret));
-  }
 }
 
@@ -162,5 +162,5 @@
   vector<unsigned short> ROICmd;
   unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 1)), 0, htons(CMD_Write | (BADDR_DAC + 2)), 0, htons(CMD_Write | (BADDR_DAC + 3)), 0};
-  string Message = string("ACALIBDONE")+Name;
+  string Message = string("ACALIBDONE")+Name+"\n";
 
   switch (State) {
@@ -540,9 +540,9 @@
 	  
 	  // Inform event thread of new data
-	  string Message = string("EVENT")+Name;
+	  string Message = string("EVENT")+Name+"\n";
 	  if (write(m->Pipe[1], Message.data(), Message.size()) == -1) {
 		m->Message(m->ERROR, "write() to Pipe[1] failed in class FADBoard (%s)", strerror(errno));
-		m->ExitRequest = true;
-	  }	    
+		break;
+	  }
 	}
 	else SetStatus("End package flag incorrect, removing corrupt event");
Index: fact/FADctrl/History.txt
===================================================================
--- fact/FADctrl/History.txt	(revision 10290)
+++ fact/FADctrl/History.txt	(revision 10291)
@@ -21,3 +21,4 @@
 			Limited update rate of slow control data to 1 second or interval set by 'update'
 1/4/2011	Added DIM frequency service
-5/4/2011	Added DIM rate service for each board		
+5/4/2011	Added DIM rate service for each board
+6/4/2011	Bug fix in internal pipe communication	
