Index: branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs
===================================================================
--- branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs	(revision 14006)
+++ branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs	(revision 14009)
@@ -22,5 +22,5 @@
     //two queues are used to gather and and provide population more efficiently
     private object activeQueueLocker = new Object();
-    private SizedConcurrentQueue<KeyValuePair<PeerInfo,byte[]>> writeQueue;
+    private SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[]>> writeQueue;
     private SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[]>> readQueue;
 
@@ -29,5 +29,4 @@
 
     private double communicationRate;
-    private Random rand;
 
     public event EventHandler<Exception> ExceptionOccurend;
@@ -42,8 +41,7 @@
 
         this.communicationRate = communicationRate;
-        rand = new Random();
 
         writeQueue = new SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[]>>();
-        readQueue = new SizedConcurrentQueue<KeyValuePair<PeerInfo,byte[]>>();
+        readQueue = new SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[]>>();
         writeQueue.Limit = messageCacheCapacity;
         readQueue.Limit = writeQueue.Limit;
@@ -54,5 +52,5 @@
 
         peerListManager = new WcfPeerListManager();
-        peerListManager.Init(ownInstance, contactServerUrl);
+        peerListManager.Init(ownInstance, contactServerUrl, communicationRate);
 
         sender = new WcfMessageSender();
@@ -78,9 +76,6 @@
     public void PublishDataToNetwork(byte[] data) {
       try {
-        var peers = peerListManager.GetPeerList();
-        foreach (PeerInfo peer in peerListManager.GetPeerList()) {
-          var peersForMessaging = ChoosePeersForMessaging(ref peers);
-
-          //maybe something will go wrong during network communication...
+        var allPeers = peerListManager.GetPeerList();
+        foreach (PeerInfo peer in allPeers) {
           try {
             sender.SendData(peer, data);
@@ -90,4 +85,5 @@
           }
         }
+
       }
       catch (Exception ex) {
@@ -99,5 +95,5 @@
       try {
         List<KeyValuePair<PeerInfo, byte[]>> res = new List<KeyValuePair<PeerInfo, byte[]>>();
-        KeyValuePair<PeerInfo,byte[]> item;
+        KeyValuePair<PeerInfo, byte[]> item;
         lock (activeQueueLocker) {
           //changing the current queue for storing items to send
@@ -131,18 +127,7 @@
 
     private void PropagateException(Exception ex) {
-      //if (CountdownCompleted != null)
-      //  CountdownCompleted(this, e);
       if (ExceptionOccurend != null) {
         ExceptionOccurend(this, ex);
       }
-    }
-
-    private List<PeerInfo> ChoosePeersForMessaging(ref List<PeerInfo> allPeers) {
-      Shuffle<PeerInfo>(allPeers);
-      int toTake = Convert.ToInt32(allPeers.Count * communicationRate) + 1;
-      if (allPeers.Count > 0 && toTake == 0) {
-        toTake = 1;
-      }
-      return allPeers.Take(toTake).ToList(); ;
     }
 
@@ -161,19 +146,8 @@
     }
 
-    private void Shuffle<T>(IList<T> list) {
-      int n = list.Count;
-      while (n > 1) {
-        n--;
-        int k = rand.Next(n + 1);
-        T value = list[k];
-        list[k] = list[n];
-        list[n] = value;
-      }
-    }
-
     private void OnDataRecieved(object sender, MessageRecieveEventArgs e) {
       if (e != null && e.Sender.ProblemInstance.Equals(ownInstance.ProblemInstance)) {
         lock (activeQueueLocker) {
-            writeQueue.Enqueue(new KeyValuePair<PeerInfo, byte[]>(e.Sender, e.data));
+          writeQueue.Enqueue(new KeyValuePair<PeerInfo, byte[]>(e.Sender, e.data));
         }
 
Index: branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs
===================================================================
--- branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs	(revision 14006)
+++ branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs	(revision 14009)
@@ -17,5 +17,4 @@
     private SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[]>> bufferedMessagesWrite;
     private SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[]>> bufferedMessagesRead;
-
 
     private Timer timer; //sends cached messages to network in background
@@ -80,5 +79,5 @@
         }
         //for (int i = 0; i <= messagePackage.Value.GetUpperBound(0); i++) {
-          cache[messagePackage.Key].Add(messagePackage.Value);
+        cache[messagePackage.Key].Add(messagePackage.Value);
         //}
       }
Index: branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs
===================================================================
--- branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs	(revision 14006)
+++ branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs	(revision 14009)
@@ -22,33 +22,31 @@
     private IContactService client;
 
-    private IContactService heartbeatClient;
+    private List<PeerInfo> cachedPeerList;
 
+    private double communicationRate;
 
+    private Random rand;
 
-    public void Init(PeerInfo source, string contactServerUrl) {
+    public void Init(PeerInfo source, string contactServerUrl, double communicationRate) {
       serverString = contactServerUrl;
+      this.communicationRate = communicationRate;
       myself = source;
-
-      //Init ChannelFactory and Clients
+      cachedPeerList = new List<PeerInfo>();
+      rand = new Random();
+      //Init ChannelFactory and Client
       var binding = new NetTcpBinding();
       var endpoint = new EndpointAddress(serverString);
       myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint);
       client = myChannelFactory.CreateChannel();
-      heartbeatClient = myChannelFactory.CreateChannel();
       //Register Peer
-      client.RegisterPeer(source);
+      client.RegisterPeer(myself);
       //Start heartbeat timer
       timer = new Timer(1000 * 20); //each 20 seconds
-      timer.Elapsed += SendHeartbeatToServer;
+      timer.Elapsed += RefreshPeerList;
       timer.Start();
     }
 
     public List<PeerInfo> GetPeerList() {
-      try {
-        var allPeers = client.GetPeerList(myself); //maybe timout exception...
-        return allPeers;
-      }
-      catch { } //if maybe sending failed (because of connection lost, etc.): just ignore
-      return new List<PeerInfo>();
+      return cachedPeerList;
     }
 
@@ -61,14 +59,33 @@
       timer.Dispose();
       ((IClientChannel)client).Close();
-      ((IClientChannel)heartbeatClient).Close();
       myChannelFactory.Close();
-      client = null;
       myChannelFactory = null;
     }
 
-    private void SendHeartbeatToServer(object sender, ElapsedEventArgs e) {
+    private List<PeerInfo> ChoosePeersForMessaging(ref List<PeerInfo> allPeers) {
+      Shuffle<PeerInfo>(allPeers);
+      int toTake = Convert.ToInt32(allPeers.Count * communicationRate) + 1;
+      if (allPeers.Count > 0 && toTake == 0) {
+        toTake = 1;
+      }
+      return allPeers.Take(toTake).ToList(); ;
+    }
+
+    private void Shuffle<T>(IList<T> list) {
+      int n = list.Count;
+      while (n > 1) {
+        n--;
+        int k = rand.Next(n + 1);
+        T value = list[k];
+        list[k] = list[n];
+        list[n] = value;
+      }
+    }
+
+    private void RefreshPeerList(object sender, ElapsedEventArgs e) {
       lock (timerLock) {
         try {
-          heartbeatClient.UpdateHeartbeat(myself);
+          var allPeers = client.GetPeerList(myself);
+          cachedPeerList = ChoosePeersForMessaging(ref allPeers);
         }
         catch { } //nothing to do
Index: branches/thasling/DistributedGA/DistributedGA.Core/Interface/IPeerListManager.cs
===================================================================
--- branches/thasling/DistributedGA/DistributedGA.Core/Interface/IPeerListManager.cs	(revision 14006)
+++ branches/thasling/DistributedGA/DistributedGA.Core/Interface/IPeerListManager.cs	(revision 14009)
@@ -6,5 +6,5 @@
   public interface IPeerListManager {
 
-    void Init(PeerInfo source, string contactServerUrl); //Registers own instance at the contact-server
+    void Init(PeerInfo source, string contactServerUrl, double communicationRate); //Registers own instance at the contact-server
 
     List<PeerInfo> GetPeerList(); //Recieves all peers in the network from contact-server
Index: branches/thasling/DistributedGA/DistributedGA.Hive/MigrationStrategy.cs
===================================================================
--- branches/thasling/DistributedGA/DistributedGA.Hive/MigrationStrategy.cs	(revision 14006)
+++ branches/thasling/DistributedGA/DistributedGA.Hive/MigrationStrategy.cs	(revision 14009)
@@ -6,4 +6,4 @@
 
 namespace DistributedGA.Hive {
-  public enum MigrationStrategy  { TakeBestReplaceBad, TakeRandomReplaceBad, TakeBestReplaceRandom, TakeRandomReplaceRandom };
+  public enum MigrationStrategy  { Best, Worst, Random };
 }
Index: branches/thasling/DistributedGA/DistributedGA.Hive/P2PMigrationAnalyzer.cs
===================================================================
--- branches/thasling/DistributedGA/DistributedGA.Hive/P2PMigrationAnalyzer.cs	(revision 14006)
+++ branches/thasling/DistributedGA/DistributedGA.Hive/P2PMigrationAnalyzer.cs	(revision 14009)
@@ -72,6 +72,10 @@
     }
 
-    public IConstrainedValueParameter<EnumValue<MigrationStrategy>> MigrationStrategyParameter {
-      get { return (IConstrainedValueParameter<EnumValue<MigrationStrategy>>)Parameters["MigrationStrategy"]; }
+    public IConstrainedValueParameter<EnumValue<MigrationStrategy>> MigrationStrategySelectParameter {
+      get { return (IConstrainedValueParameter<EnumValue<MigrationStrategy>>)Parameters["MigrationStrategySelect"]; }
+    }
+
+    public IConstrainedValueParameter<EnumValue<MigrationStrategy>> MigrationStrategyReplaceParameter {
+      get { return (IConstrainedValueParameter<EnumValue<MigrationStrategy>>)Parameters["MigrationStrategyReplace"]; }
     }
 
@@ -100,8 +104,8 @@
       Parameters.Add(new LookupParameter<BoolValue>("Maximization"));
       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", 1));
-      Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "", new IntValue(1)));
+      Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "", new IntValue(5)));
       Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "", new PercentValue(0.05)));
       Parameters.Add(new ValueParameter<PercentValue>("CommunicationRate", "", new PercentValue(0.10)));
-      Parameters.Add(new ValueParameter<IntValue>("MessageCacheCapacity", "", new IntValue(100)));
+      Parameters.Add(new ValueParameter<IntValue>("MessageCacheCapacity", "", new IntValue(1000)));
       Parameters.Add(new ValueParameter<StringValue>("LanIpPrefix", "", new StringValue("10.")));
       Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator"));
@@ -111,20 +115,14 @@
 
       var validValues = new ItemSet<EnumValue<MigrationStrategy>>();
-      validValues.Add(new EnumValue<MigrationStrategy>(MigrationStrategy.TakeBestReplaceBad));
-      validValues.Add(new EnumValue<MigrationStrategy>(MigrationStrategy.TakeBestReplaceRandom));
-      validValues.Add(new EnumValue<MigrationStrategy>(MigrationStrategy.TakeRandomReplaceBad));
-      validValues.Add(new EnumValue<MigrationStrategy>(MigrationStrategy.TakeRandomReplaceRandom));
-
-      Parameters.Add(new ConstrainedValueParameter<EnumValue<MigrationStrategy>>("MigrationStrategy", validValues, (new EnumValue<MigrationStrategy>(MigrationStrategy.TakeBestReplaceBad))));
+      validValues.Add(new EnumValue<MigrationStrategy>(MigrationStrategy.Best));
+      validValues.Add(new EnumValue<MigrationStrategy>(MigrationStrategy.Worst));
+      validValues.Add(new EnumValue<MigrationStrategy>(MigrationStrategy.Random));
+      Parameters.Add(new ConstrainedValueParameter<EnumValue<MigrationStrategy>>("MigrationStrategySelect", validValues, (new EnumValue<MigrationStrategy>(MigrationStrategy.Random))));
+      Parameters.Add(new ConstrainedValueParameter<EnumValue<MigrationStrategy>>("MigrationStrategyReplace", validValues, (new EnumValue<MigrationStrategy>(MigrationStrategy.Random))));
+
     }
 
     public override IDeepCloneable Clone(Cloner cloner) {
       return new P2PMigrationAnalyzer(this, cloner);
-    }
-
-    public override void ClearState() {
-      base.ClearState();
-      h.Dispose();
-      h = null;
     }
 
@@ -143,4 +141,6 @@
       if (h == null) {
         Init();
+        //TODO: sort population
+
       }
       if (MigrationIterationsParameter.ActualValue == null) {
@@ -160,5 +160,6 @@
         }
         var popQualities = QualityParameter.ActualValue;
-        var selectedMigStrat = MigrationStrategyParameter.Value.Value;
+        var selectedMigStratSelect = MigrationStrategySelectParameter.Value.Value;
+        var selectedMigStratReplace = MigrationStrategyReplaceParameter.Value.Value;
 
         var rand = Random;
@@ -168,16 +169,11 @@
         for (int i = 0; i < noOfEmigrants; i++) {
           //select emigrant depending on strategy
-          switch (selectedMigStrat) {
-            case MigrationStrategy.TakeBestReplaceBad:
+          switch (selectedMigStratSelect) {
+            case MigrationStrategy.Best:
               emigrants = scope.SubScopes[i];
               emigrantsList.Add(emigrants);
               break;
 
-            case MigrationStrategy.TakeBestReplaceRandom:
-              emigrants = scope.SubScopes[i];
-              emigrantsList.Add(emigrants);
-              break;
-
-            case MigrationStrategy.TakeRandomReplaceBad:
+            case MigrationStrategy.Random:
               replIdx = rand.Next(scope.SubScopes.Count);
               emigrants = scope.SubScopes[replIdx];
@@ -185,9 +181,9 @@
               break;
 
-            case MigrationStrategy.TakeRandomReplaceRandom:
-              replIdx = rand.Next(scope.SubScopes.Count);
-              emigrants = scope.SubScopes[replIdx];
+            case MigrationStrategy.Worst:
+              emigrants = scope.SubScopes[scope.SubScopes.Count - i];
               emigrantsList.Add(emigrants);
               break;
+
 
             default:
@@ -226,23 +222,17 @@
 
               // replace individual in current population
-              switch (selectedMigStrat) {
-                case MigrationStrategy.TakeBestReplaceBad:
+              switch (selectedMigStratReplace) {
+                case MigrationStrategy.Best:
                   scope.SubScopes.RemoveAt(0);
                   break;
 
-                case MigrationStrategy.TakeRandomReplaceBad:
-                  scope.SubScopes.RemoveAt(0);
-                  break;
-
-                case MigrationStrategy.TakeBestReplaceRandom:
-                  //replace random
+                case MigrationStrategy.Random:
                   replIdx = rand.Next(scope.SubScopes.Count);
                   scope.SubScopes.RemoveAt(replIdx);
                   break;
 
-                case MigrationStrategy.TakeRandomReplaceRandom:
+                case MigrationStrategy.Worst:
                   //replace random
-                  replIdx = rand.Next(scope.SubScopes.Count);
-                  scope.SubScopes.RemoveAt(replIdx);
+                  scope.SubScopes.RemoveAt(scope.SubScopes.Count);
                   break;
 
