Index: Evidence/Bridge.cc
===================================================================
--- Evidence/Bridge.cc	(revision 224)
+++ Evidence/Bridge.cc	(revision 229)
@@ -24,10 +24,8 @@
 using namespace std;
 
-
 // Class declaration
 class Bridge: public DimClient, public EvidenceServer {
 
 	struct Item {
-	  string Name;
 	  DimCommand *Command;
 	  DimStampedInfo *DataItem;
@@ -35,5 +33,5 @@
 	  char *Data;
 	};
-	vector<struct Item> List;
+	map<string, struct Item> Map;
 
 	DimInfo *ServerList;
@@ -41,7 +39,9 @@
     void infoHandler();
     void commandHandler();
+	public:
 	void AddService(string, char *, int);
 	void RemoveService(string);
-   
+	void BugFix();
+
   public:
     Bridge(char *, int);
@@ -63,5 +63,5 @@
 Bridge::~Bridge() {
 
-  while (List.size() != 0) RemoveService(List[0].Name);  
+  while (Map.size() != 0) RemoveService((*Map.begin()).first);  
   delete ServerList;
 }
@@ -77,5 +77,6 @@
 
   // If service is DIS_DNS/SERVER_LIST, subscribe to all SERVICE_LIST services
-  if (strcmp(I->getName(), "DIS_DNS/SERVER_LIST") == 0) {	
+  if (strcmp(I->getName(), "DIS_DNS/SERVER_LIST") == 0) {
+    printf("DIS_DNS/SERVER_LIST: '%s'\n", I->getString());
 	char *Token = strtok(I->getString(), "+-!@");	
 	while (Token != NULL) {
@@ -94,4 +95,13 @@
   // If service is SERVICE_LIST, scan and subscribe/unsubscribe to services
   if (strstr(I->getName(), "/SERVICE_LIST") != NULL) {
+
+	// Bug fix for empty SERVICE_LIST
+	if (strlen(I->getString()) == 0) {
+	  string Tmp(I->getName());
+	  RemoveService(I->getName());
+	  AddService(Tmp.c_str(), (char *) "C", DimSERVICE);
+	  return;
+	}
+
 	char *Format, *Name = strtok(I->getString(), "+-!|");
 	while (Name != NULL) {
@@ -131,17 +141,16 @@
   }
 
-  // Identify service and repeat to secondary DNS
-  for (int Service=0; Service<List.size(); Service++) if (I == List[Service].DataItem) {
-
-    // Copy service data
-    delete[] List[Service].Data;
-    List[Service].Data = new char [I->getSize()];
-    memcpy(List[Service].Data, I->getData(), I->getSize());
-
-	// Set new service properties and update service
-    List[Service].Service->setQuality(I->getQuality());
-    List[Service].Service->setTimestamp(I->getTimestamp(), I->getTimestampMillisecs());	
-	List[Service].Service->updateService(List[Service].Data, I->getSize());
-  }
+  // Check if service known and repeat to secondary DNS
+  if (Map.count(I->getName()) == 0) return;
+
+  // Copy service data
+  delete[] Map[I->getName()].Data;
+  Map[I->getName()].Data = new char [I->getSize()];
+  memcpy(Map[I->getName()].Data, I->getData(), I->getSize());
+
+  // Set new service properties and update service
+  Map[I->getName()].Service->setQuality(I->getQuality());
+  Map[I->getName()].Service->setTimestamp(I->getTimestamp(), I->getTimestampMillisecs());	
+  Map[I->getName()].Service->updateService(Map[I->getName()].Data, I->getSize());
 }
 
@@ -161,18 +170,17 @@
 
   // Check if already subscribed to this service
-  for (int i=0; i<List.size(); i++) {
-	if (Name == List[i].Name) return;
-  }
+  if (Map.count(Name) != 0) return;
 
   // Create subscription and service to secondary DNS or new command
-  struct Item New = {Name, NULL, NULL, NULL, NULL};
-
+  Map[Name].Command = NULL;
+  Map[Name].DataItem = NULL;
+  Map[Name].Service = NULL;
+  Map[Name].Data = NULL;
+  
   if  (Type == DimSERVICE) {  
-	New.Service = new DimService(Name.c_str(), (char *) Format, New.Data, 0);
-	New.DataItem = new DimStampedInfo(Name.c_str(), NO_LINK, this);
-  }
-  else if (Type == DimCOMMAND) New.Command = new DimCommand(Name.c_str(), Format, this);
-
-  List.push_back(New);
+	Map[Name].Service = new DimService(Name.c_str(), (char *) Format, Map[Name].Data, 0);
+	Map[Name].DataItem = new DimStampedInfo(Name.c_str(), NO_LINK, this);
+  }
+  else if (Type == DimCOMMAND) Map[Name].Command = new DimCommand(Name.c_str(), Format, this);
 }
 
@@ -181,13 +189,13 @@
 void Bridge::RemoveService(string Name) {
 
-  vector<struct Item>::iterator E;
-  for (E=List.begin(); E<List.end(); ++E) if (Name == (*E).Name) {
-	delete (*E).DataItem;
-	delete (*E).Service;
-	delete[] (*E).Data;
-	delete (*E).Command;
-
-	List.erase(E);
-  }
+  // Check if actually subscribed to service  
+  if (Map.count(Name) == 0) return;
+
+  delete Map[Name].DataItem;
+  delete Map[Name].Service;
+  delete[] Map[Name].Data;
+  delete Map[Name].Command;
+
+  Map.erase(Name);
 }
 
@@ -206,4 +214,4 @@
   
   // Sleep until signal caught
-  pause();
-}
+  while (!Class.ExitRequest) pause();
+}
