Index: branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs
===================================================================
--- branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs	(revision 13537)
+++ branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs	(revision 13538)
@@ -1,115 +1,95 @@
-﻿using DistributedGA.Core.Domain;
-using System;
+﻿using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.ServiceModel;
-using System.Text;
-using System.Threading.Tasks;
 using System.Timers;
+using DistributedGA.Core.Domain;
 
-namespace DistributedGA.ContactServer
-{
+namespace DistributedGA.ContactServer {
 
-    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
-    public class ContactServiceImpl : IContactService
-    {
+  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
+  public class ContactServiceImpl : IContactService {
 
-        private ConcurrentDictionary<PeerInfo, DateTime> allPeers = null;
+    private ConcurrentDictionary<PeerInfo, DateTime> allPeers = null;
 
-        private Timer timer = null;
+    private Timer timer = null;
 
-        public ContactServiceImpl()
-        {
-            allPeers = new ConcurrentDictionary<PeerInfo, DateTime>();
+    private Object logLock = new Object();
 
-            timer = new Timer(60 * 1000); //each hour
-            timer.Elapsed += CleanUpContactTable;
-            timer.Start();
+    public ContactServiceImpl() {
+      allPeers = new ConcurrentDictionary<PeerInfo, DateTime>();
+
+      timer = new Timer(60 * 1000); //each hour
+      timer.Elapsed += CleanUpContactTable;
+      timer.Start();
+    }
+
+    public void RegisterPeer(PeerInfo source) {
+      try {
+        UpdateHeartbeat(source);
+      } catch (Exception ex) {
+        AddError("ContactServiceImpl.RegisterPeer", ex);
+      }
+    }
+
+    public List<PeerInfo> GetPeerList(PeerInfo source) {
+      try {
+        UpdateHeartbeat(source);
+        //only return peers of the same work group and not the sender itself
+        return allPeers.Keys.Where(x => {
+          if (source.ProblemInstance.Equals(x.ProblemInstance) &&
+              (!(x.IpAddress.Equals(source.IpAddress) && (x.Port.Equals(source.Port)))))
+            return true;
+          else
+            return false;
+        }).ToList();
+      } catch (Exception ex) {
+        AddError("ContactServiceImpl.GetPeerList", ex);
+        return null;
+      }
+    }
+
+    public void MakeLog(PeerInfo source, string msg) {
+      try {
+        // TODO 
+        lock (logLock) {
+          File.AppendAllText("Log.txt", string.Concat(source.IpAddress, ":", source.Port, ",", source.ProblemInstance, ",", msg, Environment.NewLine));
         }
+      } catch (Exception ex) {
+        //Nothing to do because maybe called from adderror
+      }
+    }
 
-        public void RegisterPeer(PeerInfo source)
-        {
-            try
-            {
-                UpdateHeartbeat(source);
-            }
-            catch (Exception ex)
-            {
-                AddError("ContactServiceImpl.RegisterPeer", ex);
-            }
+    private void UpdateHeartbeat(PeerInfo source) {
+      DateTime now = DateTime.Now;
+      allPeers.AddOrUpdate(source, now, (k, v) => v = now);
+    }
+
+    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 < deadline.AddHours(1f)) {
+            itemsToDelete.Add(pi);
+          }
         }
+      }
+      //remove items
+      foreach (PeerInfo pi in itemsToDelete) {
+        DateTime tmp;
+        allPeers.TryRemove(pi, out tmp);
+      }
+    }
 
-        public List<PeerInfo> GetPeerList(PeerInfo source)
-        {
-            try
-            {
-                UpdateHeartbeat(source);
-                //only return peers of the same work group and not the sender itself
-                return allPeers.Keys.Where(x =>
-                {
-                    if (source.ProblemInstance.Equals(x.ProblemInstance) &&
-                        (!(x.IpAddress.Equals(source.IpAddress) && (x.Port.Equals(source.Port)))))
-                        return true;
-                    else
-                        return false;
-                }).ToList();
-            }
-            catch (Exception ex)
-            {
-                AddError("ContactServiceImpl.GetPeerList", ex);
-                return null;
-            }
-        }
+    private void AddError(string source, Exception ex) {
+      MakeLog(new PeerInfo() { ProblemInstance = "ContactServer  Error at " + source }, ex.Message);
+    }
 
-        public void MakeLog(PeerInfo source, string msg)
-        {
-            try
-            {
-                // TODO 
-
-            }
-            catch (Exception ex)
-            {
-                AddError("ContactServiceImpl.GetPeerList", ex);
-            }
-        }
-
-        private void UpdateHeartbeat(PeerInfo source)
-        {
-            DateTime now = DateTime.Now;
-            allPeers.AddOrUpdate(source, now, (k, v) => v = now);
-        }
-
-        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 < deadline.AddHours(1f))
-                    {
-                        itemsToDelete.Add(pi);
-                    }
-                }
-            }
-            //remove items
-            foreach (PeerInfo pi in itemsToDelete)
-            {
-                DateTime tmp;
-                allPeers.TryRemove(pi, out tmp);
-            }
-        }
-
-        private void AddError(string source, Exception ex)
-        {
-            MakeLog(new PeerInfo() { ProblemInstance = "ContactServer  Error at " + source }, ex.Message);
-        }
-
-    }
+  }
 }
Index: branches/thasling/DistributedGA/DistributedGA.ContactServer/obj/Debug/WcfConfigValidationData.tmp
===================================================================
--- branches/thasling/DistributedGA/DistributedGA.ContactServer/obj/Debug/WcfConfigValidationData.tmp	(revision 13537)
+++ branches/thasling/DistributedGA/DistributedGA.ContactServer/obj/Debug/WcfConfigValidationData.tmp	(revision 13538)
@@ -1,1 +1,1 @@
-<ValidationRecord xmlns="http://schemas.datacontract.org/2004/07/Microsoft.VisualStudio.ServiceModel.Validation" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><TimeStamps xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:dateTime>2016-01-18T09:27:09.7709563Z</a:dateTime><a:dateTime>2016-01-18T09:31:18.4519841Z</a:dateTime><a:dateTime>2015-04-01T13:05:26.8346639Z</a:dateTime></TimeStamps></ValidationRecord>
+<ValidationRecord xmlns="http://schemas.datacontract.org/2004/07/Microsoft.VisualStudio.ServiceModel.Validation" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><TimeStamps xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:dateTime>2016-01-18T10:18:36.7404261Z</a:dateTime><a:dateTime>2016-01-18T12:23:29.9363892Z</a:dateTime><a:dateTime>2015-04-01T13:05:26.8346639Z</a:dateTime></TimeStamps></ValidationRecord>
