Index: /branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs
===================================================================
--- /branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs	(revision 13942)
+++ /branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs	(revision 13943)
@@ -18,4 +18,6 @@
 
     private Object logLock = new Object();
+
+    private Object timerLock = new Object();//if elapsed takes too long, another thread also enters the method
 
     public ContactServiceImpl() {
@@ -78,23 +80,25 @@
 
     private void CleanUpContactTable(object sender, ElapsedEventArgs e) {
-      DateTime deadline = DateTime.Now;
-      //collect items to remove
-      List<PeerInfo> itemsToDelete = new List<PeerInfo>();
-      foreach (PeerInfo pi in allPeers.Keys) {
-        DateTime tmp;
-        if (allPeers.TryGetValue(pi, out tmp)) {
-          //if (tmp.AddHours(1f) < deadline)
-          if (tmp.AddMinutes(1) < deadline)  //TODO
+      lock (timerLock) {
+        DateTime deadline = DateTime.Now;
+        //collect items to remove
+        List<PeerInfo> itemsToDelete = new List<PeerInfo>();
+        foreach (PeerInfo pi in allPeers.Keys) {
+          DateTime tmp;
+          if (allPeers.TryGetValue(pi, out tmp)) {
+            //if (tmp.AddHours(1f) < deadline)
+            if (tmp.AddMinutes(1) < deadline)  //TODO
                     {
-            //if (tmp < deadline.AddHours(1f)) {
-            itemsToDelete.Add(pi);
+              //if (tmp < deadline.AddHours(1f)) {
+              itemsToDelete.Add(pi);
+            }
           }
         }
-      }
-      //remove items
-      foreach (PeerInfo pi in itemsToDelete) {
-        DateTime tmp;
-        allPeers.TryRemove(pi, out tmp);
-        Console.WriteLine(string.Format("Removed peer {0}:{1} from dictionary because last access was: {2}", pi.IpAddress, pi.Port, tmp));
+        //remove items
+        foreach (PeerInfo pi in itemsToDelete) {
+          DateTime tmp;
+          allPeers.TryRemove(pi, out tmp);
+          Console.WriteLine(string.Format("Removed peer {0}:{1} from dictionary because last access was: {2}", pi.IpAddress, pi.Port, tmp));
+        }
       }
     }
Index: /branches/thasling/DistributedGA/DistributedGA.ContactServer/DistributedGA.ContactServer.csproj
===================================================================
--- /branches/thasling/DistributedGA/DistributedGA.ContactServer/DistributedGA.ContactServer.csproj	(revision 13942)
+++ /branches/thasling/DistributedGA/DistributedGA.ContactServer/DistributedGA.ContactServer.csproj	(revision 13943)
@@ -55,5 +55,7 @@
   </ItemGroup>
   <ItemGroup>
-    <None Include="App.config" />
+    <None Include="App.config">
+      <SubType>Designer</SubType>
+    </None>
   </ItemGroup>
   <ItemGroup>
Index: /branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs
===================================================================
--- /branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs	(revision 13942)
+++ /branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs	(revision 13943)
@@ -18,8 +18,10 @@
     private Timer timer; //sends cached messages to network in background
 
+    private Object timerLock = new Object();
+
     public void Init(PeerInfo source) {
       myself = source;
       bufferedMessages = new SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[][]>>();
-      bufferedMessages.Limit = 1000;
+      bufferedMessages.Limit = 100000;
       timer = new Timer(1000 * 60); //each 5 minutes
       timer.Elapsed += GenerateSendingTasks;
@@ -52,19 +54,21 @@
     /// <param name="data">data to send</param>
     private void SendDataFromQueue(PeerInfo destination, byte[][] data) {
-      try {
-        Console.WriteLine(string.Format("Sending data to {0}:{1} in the background...", destination.IpAddress, destination.Port));
-        var serviceUrl = "DistributedGA.svc";
-        var baseUri = new Uri(string.Concat("net.tcp://", destination.IpAddress, ":", destination.Port, "/DistributedGA"));
-        var serviceUri = new Uri(baseUri, serviceUrl);
+      lock (timerLock) {
+        try {
+          Console.WriteLine(string.Format("Sending data to {0}:{1} in the background...", destination.IpAddress, destination.Port));
+          var serviceUrl = "DistributedGA.svc";
+          var baseUri = new Uri(string.Concat("net.tcp://", destination.IpAddress, ":", destination.Port, "/DistributedGA"));
+          var serviceUri = new Uri(baseUri, serviceUrl);
 
-        var binding = new NetTcpBinding();
-        var endpoint = new EndpointAddress(serviceUri);
-        using (var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint)) {
-          using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) {
-            ((IMessageContract)client).SendData(myself, data); //maybe timout exception...
+          var binding = new NetTcpBinding();
+          var endpoint = new EndpointAddress(serviceUri);
+          using (var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint)) {
+            using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) {
+              ((IMessageContract)client).SendData(myself, data); //maybe timout exception...
+            }
           }
         }
+        catch { } //if maybe sending failed (because of connection lost, etc.): just ignore
       }
-      catch { } //if maybe sending failed (because of connection lost, etc.): just ignore
     }
   }
Index: /branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs
===================================================================
--- /branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs	(revision 13942)
+++ /branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs	(revision 13943)
@@ -15,4 +15,6 @@
 
     private Timer timer = null; //sends heartbeat to contact-server
+
+    private Object timerLock = new Object();
 
     private ChannelFactory<IContactService> myChannelFactory;
@@ -73,5 +75,5 @@
         res.Add(allPeers.ElementAt(index));
       }
-      return res;
+      return allPeers;
     }
 
@@ -90,8 +92,10 @@
 
     private void SendHeartbeatToServer(object sender, ElapsedEventArgs e) {
-      try {
-        heartbeatClient.UpdateHeartbeat(myself);
+      lock (timerLock) {
+        try {
+          heartbeatClient.UpdateHeartbeat(myself);
+        }
+        catch { } //nothing to do
       }
-      catch { } //nothing to do
     }
 
Index: /branches/thasling/DistributedGA/DistributedGA.Hive/P2PMigrationAnalyzer.cs
===================================================================
--- /branches/thasling/DistributedGA/DistributedGA.Hive/P2PMigrationAnalyzer.cs	(revision 13942)
+++ /branches/thasling/DistributedGA/DistributedGA.Hive/P2PMigrationAnalyzer.cs	(revision 13943)
@@ -97,9 +97,9 @@
       // init P2P
       h = new PeerNetworkMessageHandler();
-      var peer = h.GetPeerInfo();
-      peer.ProblemInstance = ((StringValue)Parameters["JobGUID"].ActualValue).Value;
       var lanIpPrefix = ((StringValue)(Parameters["LanIpPrefix"].ActualValue)).Value;
       var contactServerUri = ((StringValue)(Parameters["ContactServerURL"].ActualValue)).Value;
       h.Init(lanIpPrefix, contactServerUri);
+      var peer = h.GetPeerInfo();
+      peer.ProblemInstance = ((StringValue)Parameters["JobGUID"].ActualValue).Value;
     }
 
