Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.Designer.cs	(revision 5163)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.Designer.cs	(revision 5237)
@@ -26,16 +26,4 @@
     /// </summary>
     private System.ComponentModel.IContainer components = null;
-
-    /// <summary> 
-    /// Clean up any resources being used.
-    /// </summary>
-    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-    protected override void Dispose(bool disposing) {
-      if (disposing) {
-        if (problemTypeSelectorDialog != null) problemTypeSelectorDialog.Dispose();
-        if (components != null) components.Dispose();
-      }
-      base.Dispose(disposing);
-    }
 
     #region Component Designer generated code
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs	(revision 5163)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs	(revision 5237)
@@ -49,4 +49,12 @@
     public AlgorithmView() {
       InitializeComponent();
+    }
+
+    protected override void Dispose(bool disposing) {
+      if (disposing) {
+        if (problemTypeSelectorDialog != null) problemTypeSelectorDialog.Dispose();
+        if (components != null) components.Dispose();
+      }
+      base.Dispose(disposing);
     }
 
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs	(revision 5163)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs	(revision 5237)
@@ -26,16 +26,4 @@
     /// </summary>
     private System.ComponentModel.IContainer components = null;
-
-    /// <summary> 
-    /// Clean up any resources being used.
-    /// </summary>
-    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-    protected override void Dispose(bool disposing) {
-      if (disposing) {
-        if (algorithmTypeSelectorDialog != null) algorithmTypeSelectorDialog.Dispose();
-        if (components != null) components.Dispose();
-      }
-      base.Dispose(disposing);
-    }
 
     #region Component Designer generated code
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs	(revision 5163)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs	(revision 5237)
@@ -47,4 +47,12 @@
     public BatchRunView() {
       InitializeComponent();
+    }
+
+    protected override void Dispose(bool disposing) {
+      if (disposing) {
+        if (algorithmTypeSelectorDialog != null) algorithmTypeSelectorDialog.Dispose();
+        if (components != null) components.Dispose();
+      }
+      base.Dispose(disposing);
     }
 
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs	(revision 5163)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs	(revision 5237)
@@ -23,5 +23,4 @@
 using System.Drawing;
 using System.Windows.Forms;
-using HeuristicLab.Collections;
 using HeuristicLab.Core;
 using HeuristicLab.Core.Views;
@@ -60,47 +59,20 @@
     protected override ListViewItem CreateListViewItem(IRunCollectionConstraint item) {
       ListViewItem listViewItem = base.CreateListViewItem(item);
-      if (item.Active)
-        listViewItem.Font = new Font(listViewItem.Font, FontStyle.Bold);
-      else
-        listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular);
+      if (item != null) {
+        listViewItem.Font = item.Active ? new Font(listViewItem.Font, FontStyle.Bold) : new Font(listViewItem.Font, FontStyle.Regular);
+      }
       return listViewItem;
     }
 
-    protected override void RegisterContentEvents() {
-      base.RegisterContentEvents();
-      foreach (IRunCollectionConstraint constraint in Content)
-        RegisterConstraintEvents(constraint);
+    protected override void DeregisterItemEvents(IRunCollectionConstraint item) {
+      item.ActiveChanged -= new EventHandler(Item_ActiveChanged);
+      base.DeregisterItemEvents(item);
     }
-    protected override void DeregisterContentEvents() {
-      base.DeregisterContentEvents();
-      foreach (IRunCollectionConstraint constraint in Content)
-        DeregisterConstraintEvents(constraint);
-    }
-    protected override void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
-      base.Content_ItemsAdded(sender, e);
-      foreach (IRunCollectionConstraint constraint in e.Items)
-        RegisterConstraintEvents(constraint);
-
-    }
-    protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
-      base.Content_ItemsRemoved(sender, e);
-      foreach (IRunCollectionConstraint constraint in e.Items)
-        DeregisterConstraintEvents(constraint);
-    }
-    protected override void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
-      base.Content_CollectionReset(sender, e);
-      foreach (IRunCollectionConstraint constraint in e.OldItems)
-        RegisterConstraintEvents(constraint);
-      foreach (IRunCollectionConstraint constraint in e.Items)
-        DeregisterConstraintEvents(constraint);
+    protected override void RegisterItemEvents(IRunCollectionConstraint item) {
+      base.RegisterItemEvents(item);
+      item.ActiveChanged += new EventHandler(Item_ActiveChanged);
     }
 
-    protected virtual void RegisterConstraintEvents(IRunCollectionConstraint constraint) {
-      constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged);
-    }
-    protected virtual void DeregisterConstraintEvents(IRunCollectionConstraint constraint) {
-      constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged);
-    }
-    protected virtual void constraint_ActiveChanged(object sender, EventArgs e) {
+    protected virtual void Item_ActiveChanged(object sender, EventArgs e) {
       IRunCollectionConstraint constraint = (IRunCollectionConstraint)sender;
       foreach (ListViewItem listViewItem in GetListViewItemsForItem(constraint)) {
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.Designer.cs	(revision 5163)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.Designer.cs	(revision 5237)
@@ -20,5 +20,4 @@
 #endregion
 
-using System;
 using System.Windows.Forms;
 
@@ -36,8 +35,4 @@
     protected override void Dispose(bool disposing) {
       if (disposing) {
-        foreach (ListViewItem item in itemsListView.Items) {
-          ((IRun)item.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged);
-          ((IRun)item.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);
-        }
         if (components != null) components.Dispose();
       }
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs	(revision 5163)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs	(revision 5237)
@@ -36,5 +36,5 @@
   [Content(typeof(IItemCollection<IRun>), false)]
   public sealed partial class RunCollectionView : ItemView {
-    private Dictionary<IRun, List<ListViewItem>> runListViewItemMapping;
+    private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping;
 
     public new IItemCollection<IRun> Content {
@@ -54,5 +54,5 @@
       InitializeComponent();
       itemsGroupBox.Text = "Runs";
-      runListViewItemMapping = new Dictionary<IRun, List<ListViewItem>>();
+      itemListViewItemMapping = new Dictionary<IRun, List<ListViewItem>>();
     }
 
@@ -61,5 +61,7 @@
       Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
       Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
-      DeregisterRunEvents(Content);
+      foreach (IRun run in itemListViewItemMapping.Keys) {
+        DeregisterItemEvents(run);
+      }
       base.DeregisterContentEvents();
     }
@@ -69,13 +71,14 @@
       Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
       Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
-      RegisterRunEvents(Content);
-    }
-    private void RegisterRunEvents(IEnumerable<IRun> runs) {
-      foreach (IRun run in runs)
-        run.Changed += new EventHandler(Run_Changed);
-    }
-    private void DeregisterRunEvents(IEnumerable<IRun> runs) {
-      foreach (IRun run in runs)
-        run.Changed -= new EventHandler(Run_Changed);
+    }
+    private void DeregisterItemEvents(IRun item) {
+      item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged);
+      item.ToStringChanged -= new EventHandler(Item_ToStringChanged);
+      item.Changed -= new EventHandler(Item_Changed);
+    }
+    private void RegisterItemEvents(IRun item) {
+      item.ItemImageChanged += new EventHandler(Item_ItemImageChanged);
+      item.ToStringChanged += new EventHandler(Item_ToStringChanged);
+      item.Changed += new EventHandler(Item_Changed);
     }
 
@@ -101,5 +104,7 @@
         selectedName = ((IRun)itemsListView.SelectedItems[0].Tag).Name;
 
-      while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]);
+      itemsListView.Items.Clear();
+      itemListViewItemMapping.Clear();
+      RebuildImageList();
       viewHost.Content = null;
 
@@ -148,16 +153,22 @@
     private ListViewItem CreateListViewItem(IRun item) {
       ListViewItem listViewItem = new ListViewItem();
-      listViewItem.Text = item.ToString();
-      listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription;
-      itemsListView.SmallImageList.Images.Add(item.ItemImage);
-      listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
-      listViewItem.Tag = item;
-
-      if (item.Visible) {
-        listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular);
-        listViewItem.ForeColor = item.Color;
+      if (item == null) {
+        listViewItem.Text = "null";
+        itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing);
+        listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
       } else {
-        listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic);
-        listViewItem.ForeColor = Color.LightGray;
+        listViewItem.Text = item.ToString();
+        listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription;
+        itemsListView.SmallImageList.Images.Add(item.ItemImage);
+        listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
+        listViewItem.Tag = item;
+
+        if (item.Visible) {
+          listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular);
+          listViewItem.ForeColor = item.Color;
+        } else {
+          listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic);
+          listViewItem.ForeColor = Color.LightGray;
+        }
       }
       return listViewItem;
@@ -167,9 +178,9 @@
       IRun run = listViewItem.Tag as IRun;
       if (run != null) {
-        if (!runListViewItemMapping.ContainsKey(run))
-          runListViewItemMapping.Add(run, new List<ListViewItem>());
-        runListViewItemMapping[run].Add(listViewItem);
-        run.ItemImageChanged += new EventHandler(Item_ItemImageChanged);
-        run.ToStringChanged += new EventHandler(Item_ToStringChanged);
+        if (!itemListViewItemMapping.ContainsKey(run)) {
+          itemListViewItemMapping.Add(run, new List<ListViewItem>());
+          RegisterItemEvents(run);
+        }
+        itemListViewItemMapping[run].Add(listViewItem);
       }
     }
@@ -177,28 +188,34 @@
       IRun run = listViewItem.Tag as IRun;
       if (run != null) {
-        runListViewItemMapping[run].Remove(listViewItem);
-        if (runListViewItemMapping[run].Count == 0) {
-          runListViewItemMapping.Remove(run);
-          run.ItemImageChanged -= new EventHandler(Item_ItemImageChanged);
-          run.ToStringChanged -= new EventHandler(Item_ToStringChanged);
+        itemListViewItemMapping[run].Remove(listViewItem);
+        if (itemListViewItemMapping[run].Count == 0) {
+          DeregisterItemEvents(run);
+          itemListViewItemMapping.Remove(run);
         }
       }
       listViewItem.Remove();
-      foreach (ListViewItem other in itemsListView.Items)
-        if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--;
-      itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex);
     }
     private void UpdateListViewItemImage(ListViewItem listViewItem) {
+      IRun item = listViewItem.Tag as IRun;
       int i = listViewItem.ImageIndex;
-      listViewItem.ImageList.Images[i] = ((IRun)listViewItem.Tag).ItemImage;
+      listViewItem.ImageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing : item.ItemImage;
       listViewItem.ImageIndex = -1;
       listViewItem.ImageIndex = i;
     }
     private void UpdateListViewItemText(ListViewItem listViewItem) {
-      if (!listViewItem.Text.Equals(listViewItem.Tag.ToString()))
-        listViewItem.Text = listViewItem.Tag.ToString();
-    }
-    private IEnumerable<ListViewItem> GetListViewItemsForItem(IRun run) {
-      return runListViewItemMapping[run];
+      IRun item = listViewItem.Tag as IRun;
+      listViewItem.Text = item == null ? "null" : item.ToString();
+      listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription;
+    }
+    private IEnumerable<ListViewItem> GetListViewItemsForItem(IRun item) {
+      if (item == null) {
+        List<ListViewItem> listViewItems = new List<ListViewItem>();
+        foreach (ListViewItem listViewItem in itemsListView.Items) {
+          if (listViewItem.Tag == null) listViewItems.Add(listViewItem);
+        }
+        return listViewItems;
+      } else {
+        return itemListViewItemMapping[item];
+      }
     }
 
@@ -228,9 +245,11 @@
     private void itemsListView_DoubleClick(object sender, EventArgs e) {
       if (itemsListView.SelectedItems.Count == 1) {
-        IRun item = (IRun)itemsListView.SelectedItems[0].Tag;
-        IContentView view = MainFormManager.MainForm.ShowContent(item);
-        if (view != null) {
-          view.ReadOnly = ReadOnly;
-          view.Locked = Locked;
+        IRun item = itemsListView.SelectedItems[0].Tag as IRun;
+        if (item != null) {
+          IContentView view = MainFormManager.MainForm.ShowContent(item);
+          if (view != null) {
+            view.ReadOnly = ReadOnly;
+            view.Locked = Locked;
+          }
         }
       }
@@ -239,14 +258,16 @@
       if (!Locked) {
         ListViewItem listViewItem = (ListViewItem)e.Item;
-        IRun item = (IRun)listViewItem.Tag;
-        DataObject data = new DataObject();
-        data.SetData("Type", item.GetType());
-        data.SetData("Value", item);
-        if (Content.IsReadOnly || ReadOnly) {
-          DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link);
-        } else {
-          DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move);
-          if ((result & DragDropEffects.Move) == DragDropEffects.Move)
-            Content.Remove(item);
+        IRun item = listViewItem.Tag as IRun;
+        if (item != null) {
+          DataObject data = new DataObject();
+          data.SetData("Type", item.GetType());
+          data.SetData("Value", item);
+          if (Content.IsReadOnly || ReadOnly) {
+            DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link);
+          } else {
+            DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move);
+            if ((result & DragDropEffects.Move) == DragDropEffects.Move)
+              Content.Remove(item);
+          }
         }
       }
@@ -312,5 +333,4 @@
         Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
       else {
-        RegisterRunEvents(e.Items);
         foreach (IRun item in e.Items)
           AddListViewItem(CreateListViewItem(item));
@@ -326,5 +346,4 @@
         Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e);
       else {
-        DeregisterRunEvents(e.Items);
         foreach (IRun item in e.Items) {
           //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection
@@ -332,4 +351,5 @@
           if (listViewItem != null) RemoveListViewItem(listViewItem);
         }
+        RebuildImageList();
         analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
         clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
@@ -341,10 +361,10 @@
         Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e);
       else {
-        DeregisterRunEvents(e.OldItems);
         foreach (IRun item in e.OldItems) {
+          //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection
           ListViewItem listViewItem = GetListViewItemsForItem(item).FirstOrDefault();
           if (listViewItem != null) RemoveListViewItem(listViewItem);
         }
-        RegisterRunEvents(e.Items);
+        RebuildImageList();
         foreach (IRun item in e.Items)
           AddListViewItem(CreateListViewItem(item));
@@ -378,7 +398,7 @@
       }
     }
-    private void Run_Changed(object sender, EventArgs e) {
-      if (InvokeRequired)
-        this.Invoke(new EventHandler(Run_Changed), sender, e);
+    private void Item_Changed(object sender, EventArgs e) {
+      if (InvokeRequired)
+        this.Invoke(new EventHandler(Item_Changed), sender, e);
       else {
         IRun run = (IRun)sender;
@@ -408,4 +428,11 @@
       }
     }
+    private void RebuildImageList() {
+      itemsListView.SmallImageList.Images.Clear();
+      foreach (ListViewItem item in itemsListView.Items) {
+        itemsListView.SmallImageList.Images.Add(((IRun)item.Tag).ItemImage);
+        item.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
+      }
+    }
     #endregion
   }
