Index: branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBAlgorithm.cs
===================================================================
--- branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBAlgorithm.cs	(revision 5666)
+++ branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBAlgorithm.cs	(revision 5667)
@@ -24,4 +24,5 @@
 using System.Drawing;
 using System.IO;
+using System.Linq;
 using HeuristicLab.Collections;
 using HeuristicLab.Common;
@@ -43,7 +44,7 @@
     }
     private IAlgorithm algorithm;
-    public IAlgorithm Algorithm {
+    private IAlgorithm Algorithm {
       get { return algorithm; }
-      private set {
+      set {
         if (value == null) throw new ArgumentNullException("Algorithm", "Algorithm cannot be null.");
         if (value != algorithm) {
@@ -77,8 +78,6 @@
     public IEnumerable<IOptimizer> NestedOptimizers {
       get {
-        if (Algorithm == null) yield break;
-        yield return Algorithm;
-        foreach (IOptimizer optimizer in Algorithm.NestedOptimizers)
-          yield return optimizer;
+        // inner algorithm cannot be accessed directly
+        return Enumerable.Empty<IOptimizer>();
       }
     }
@@ -135,6 +134,4 @@
       set { Algorithm.StoreAlgorithmInEachRun = value; }
     }
-
-
 
     #region Persistence Properties
@@ -204,4 +201,8 @@
     }
 
+    public IAlgorithm CloneAlgorithm() {
+      return (IAlgorithm)Algorithm.Clone();
+    }
+
     public void CollectParameterValues(IDictionary<string, IItem> values) {
       Algorithm.CollectParameterValues(values);
@@ -287,5 +288,12 @@
     private void OnStopped() {
       runsCounter++;
-      runs.Add(new HeuristicLab.Optimization.Run(string.Format("{0} Run {1}", Name, runsCounter), this));
+      if (Problem is OKBProblem) {
+        OKBProblem problem = (OKBProblem)Problem;
+        OKBRun run = new OKBRun(AlgorithmId, problem.ProblemId, new HeuristicLab.Optimization.Run(string.Format("{0} Run {1}", Name, runsCounter), this));
+        runs.Add(run);
+        run.Store();
+      } else {
+        runs.Add(new HeuristicLab.Optimization.Run(string.Format("{0} Run {1}", Name, runsCounter), this));
+      }
       var handler = Stopped;
       if (handler != null) handler(this, EventArgs.Empty);
Index: branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBProblem.cs
===================================================================
--- branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBProblem.cs	(revision 5666)
+++ branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBProblem.cs	(revision 5667)
@@ -42,5 +42,5 @@
     }
     private IProblem problem;
-    public IProblem Problem {
+    protected IProblem Problem {
       get { return problem; }
       private set {
@@ -153,4 +153,8 @@
     }
 
+    public IProblem CloneProblem() {
+      return (IProblem)Problem.Clone();
+    }
+
     public void CollectParameterValues(IDictionary<string, IItem> values) {
       Problem.CollectParameterValues(values);
Index: branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBRun.cs
===================================================================
--- branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBRun.cs	(revision 5666)
+++ branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBRun.cs	(revision 5667)
@@ -23,8 +23,11 @@
 using System.Collections.Generic;
 using System.Drawing;
+using System.IO;
+using System.Linq;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
 using HeuristicLab.Optimization;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Persistence.Default.Xml;
 
 namespace HeuristicLab.Clients.OKB.RunCreation {
@@ -34,7 +37,10 @@
     public string Filename { get; set; }
 
-    private long runId;
-    public long RunId {
-      get { return runId; }
+    private long algorithmId;
+    private long problemId;
+    private DateTime createdDate;
+    private bool stored;
+    public bool Stored {
+      get { return stored; }
     }
 
@@ -59,8 +65,8 @@
 
     #region Persistence Properties
-    [Storable(Name = "RunId")]
-    private long StorableRunId {
-      get { return runId; }
-      set { runId = value; }
+    [Storable(Name = "Stored")]
+    private bool StorableStored {
+      get { return stored; }
+      set { stored = value; }
     }
     #endregion
@@ -70,13 +76,33 @@
     private OKBRun(OKBRun original, Cloner cloner)
       : base(original, cloner) {
-      runId = original.runId;
+      stored = original.stored;
     }
-    public OKBRun(IRun run)
+    public OKBRun(long algorithmId, long problemId, IRun run)
       : base(run) {
-      runId = -1;
+      this.algorithmId = algorithmId;
+      this.problemId = problemId;
+      this.createdDate = DateTime.Now;
+      this.stored = false;
     }
 
     public override IDeepCloneable Clone(Cloner cloner) {
       return new OKBRun(this, cloner);
+    }
+
+    public void Store() {
+      if (stored) throw new InvalidOperationException("Cannot store already stored run.");
+
+      Run run = new Run();
+      run.AlgorithmId = algorithmId;
+      run.ProblemId = problemId;
+      run.UserId = Guid.Empty;
+      run.ClientId = Guid.Empty;
+      run.CreatedDate = createdDate;
+      run.RandomSeed = Parameters.Where(x => (x.Key == "Seed") && (x.Value is Data.IntValue)).Select(x => ((Data.IntValue)x.Value).Value).FirstOrDefault();
+      run.ParameterValues = ConvertToValues(Parameters);
+      run.ResultValues = ConvertToValues(Results);
+      RunCreationClient.Instance.AddRun(run);
+
+      stored = true;
     }
 
@@ -101,4 +127,48 @@
     }
     #endregion
+
+    #region Helpers
+    List<Value> ConvertToValues(IDictionary<string, IItem> items) {
+      List<Value> values = new List<Value>();
+      foreach (var item in items) {
+        Value value;
+        if (item.Value is Data.BoolValue) {
+          BoolValue v = new BoolValue();
+          v.Value = ((Data.BoolValue)item.Value).Value;
+          value = v;
+        } else if (item.Value is Data.IntValue) {
+          IntValue v = new IntValue();
+          v.Value = ((Data.IntValue)item.Value).Value;
+          value = v;
+        } else if (item.Value is Data.DoubleValue) {
+          DoubleValue v = new DoubleValue();
+          v.Value = ((Data.DoubleValue)item.Value).Value;
+          value = v;
+        } else if (item.Value is Data.StringValue) {
+          StringValue v = new StringValue();
+          v.Value = ((Data.StringValue)item.Value).Value;
+          value = v;
+        } else if (item.Value is Data.IntValue) {
+          IntValue v = new IntValue();
+          v.Value = ((Data.IntValue)item.Value).Value;
+          value = v;
+        } else {
+          BinaryValue v = new BinaryValue();
+          using (MemoryStream stream = new MemoryStream()) {
+            XmlGenerator.Serialize(item.Value, stream);
+            stream.Close();
+            v.Value = stream.ToArray();
+          }
+          value = v;
+        }
+        value.Name = item.Key;
+        value.DataType = new DataType();
+        value.DataType.Name = item.Value.GetType().Name;
+        value.DataType.TypeName = item.Value.GetType().AssemblyQualifiedName;
+        values.Add(value);
+      }
+      return values;
+    }
+    #endregion
   }
 }
Index: branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBAlgorithmView.Designer.cs
===================================================================
--- branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBAlgorithmView.Designer.cs	(revision 5666)
+++ branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBAlgorithmView.Designer.cs	(revision 5667)
@@ -415,23 +415,23 @@
     #endregion
 
-    protected HeuristicLab.MainForm.WindowsForms.DragOverTabControl tabControl;
-    protected System.Windows.Forms.TabPage parametersTabPage;
-    protected System.Windows.Forms.TabPage problemTabPage;
-    protected HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView;
-    protected HeuristicLab.MainForm.WindowsForms.ViewHost problemViewHost;
-    protected System.Windows.Forms.Button newProblemButton;
-    protected System.Windows.Forms.Button openProblemButton;
-    protected System.Windows.Forms.Button startButton;
-    protected System.Windows.Forms.Button pauseButton;
-    protected System.Windows.Forms.Button resetButton;
-    protected System.Windows.Forms.Label executionTimeLabel;
-    protected System.Windows.Forms.TextBox executionTimeTextBox;
-    protected System.Windows.Forms.OpenFileDialog openFileDialog;
-    protected System.Windows.Forms.TabPage resultsTabPage;
-    protected HeuristicLab.Optimization.Views.ResultCollectionView resultsView;
-    protected System.Windows.Forms.Button stopButton;
-    protected System.Windows.Forms.TabPage runsTabPage;
-    protected RunCollectionView runsView;
-    protected System.Windows.Forms.CheckBox storeAlgorithmInEachRunCheckBox;
+    private HeuristicLab.MainForm.WindowsForms.DragOverTabControl tabControl;
+    private System.Windows.Forms.TabPage parametersTabPage;
+    private System.Windows.Forms.TabPage problemTabPage;
+    private HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView;
+    private HeuristicLab.MainForm.WindowsForms.ViewHost problemViewHost;
+    private System.Windows.Forms.Button newProblemButton;
+    private System.Windows.Forms.Button openProblemButton;
+    private System.Windows.Forms.Button startButton;
+    private System.Windows.Forms.Button pauseButton;
+    private System.Windows.Forms.Button resetButton;
+    private System.Windows.Forms.Label executionTimeLabel;
+    private System.Windows.Forms.TextBox executionTimeTextBox;
+    private System.Windows.Forms.OpenFileDialog openFileDialog;
+    private System.Windows.Forms.TabPage resultsTabPage;
+    private HeuristicLab.Optimization.Views.ResultCollectionView resultsView;
+    private System.Windows.Forms.Button stopButton;
+    private System.Windows.Forms.TabPage runsTabPage;
+    private RunCollectionView runsView;
+    private System.Windows.Forms.CheckBox storeAlgorithmInEachRunCheckBox;
     private System.Windows.Forms.ComboBox algorithmComboBox;
     private System.Windows.Forms.Label algorithmLabel;
Index: branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBAlgorithmView.cs
===================================================================
--- branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBAlgorithmView.cs	(revision 5666)
+++ branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBAlgorithmView.cs	(revision 5667)
@@ -34,5 +34,5 @@
   [View("OKBAlgorithm View")]
   [Content(typeof(OKBAlgorithm), true)]
-  public partial class OKBAlgorithmView : NamedItemView {
+  public sealed partial class OKBAlgorithmView : NamedItemView {
     private TypeSelectorDialog problemTypeSelectorDialog;
 
@@ -124,5 +124,5 @@
       base.SetEnabledStateOfControls();
       algorithmComboBox.Enabled = (Content != null) && !ReadOnly && !Locked && (algorithmComboBox.Items.Count > 0);
-      cloneAlgorithmButton.Enabled = (Content != null) && (Content.Problem != null) && !ReadOnly && !Locked;
+      cloneAlgorithmButton.Enabled = (Content != null) && (Content.AlgorithmId != -1) && !ReadOnly && !Locked;
       refreshButton.Enabled = (Content != null) && !ReadOnly && !Locked;
       parameterCollectionView.Enabled = Content != null;
@@ -174,10 +174,8 @@
       if (InvokeRequired)
         Invoke(new EventHandler(Content_AlgorithmChanged), sender, e);
-      else {
-        algorithmComboBox.SelectedItem = RunCreationClient.Instance.Algorithms.FirstOrDefault(x => x.Id == Content.AlgorithmId);
+      else
         OnContentChanged();
-      }
-    }
-    protected virtual void Content_ProblemChanged(object sender, EventArgs e) {
+    }
+    private void Content_ProblemChanged(object sender, EventArgs e) {
       if (InvokeRequired)
         Invoke(new EventHandler(Content_ProblemChanged), sender, e);
@@ -187,5 +185,5 @@
       }
     }
-    protected virtual void Content_ExecutionStateChanged(object sender, EventArgs e) {
+    private void Content_ExecutionStateChanged(object sender, EventArgs e) {
       if (InvokeRequired)
         Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e);
@@ -193,5 +191,5 @@
         startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
     }
-    protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
+    private void Content_ExecutionTimeChanged(object sender, EventArgs e) {
       if (InvokeRequired)
         Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
@@ -199,5 +197,5 @@
         executionTimeTextBox.Text = Content == null ? "-" : Content.ExecutionTime.ToString();
     }
-    protected virtual void Content_StoreAlgorithmInEachRunChanged(object sender, EventArgs e) {
+    private void Content_StoreAlgorithmInEachRunChanged(object sender, EventArgs e) {
       if (InvokeRequired)
         Invoke(new EventHandler(Content_StoreAlgorithmInEachRunChanged), sender, e);
@@ -205,5 +203,5 @@
         storeAlgorithmInEachRunCheckBox.Checked = Content.StoreAlgorithmInEachRun;
     }
-    protected virtual void Content_Prepared(object sender, EventArgs e) {
+    private void Content_Prepared(object sender, EventArgs e) {
       if (InvokeRequired)
         Invoke(new EventHandler(Content_Prepared), sender, e);
@@ -214,5 +212,5 @@
       }
     }
-    protected virtual void Content_Started(object sender, EventArgs e) {
+    private void Content_Started(object sender, EventArgs e) {
       if (InvokeRequired)
         Invoke(new EventHandler(Content_Started), sender, e);
@@ -222,5 +220,5 @@
       }
     }
-    protected virtual void Content_Paused(object sender, EventArgs e) {
+    private void Content_Paused(object sender, EventArgs e) {
       if (InvokeRequired)
         Invoke(new EventHandler(Content_Paused), sender, e);
@@ -230,5 +228,5 @@
       }
     }
-    protected virtual void Content_Stopped(object sender, EventArgs e) {
+    private void Content_Stopped(object sender, EventArgs e) {
       if (InvokeRequired)
         Invoke(new EventHandler(Content_Stopped), sender, e);
@@ -238,5 +236,5 @@
       }
     }
-    protected virtual void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) {
+    private void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) {
       if (InvokeRequired)
         Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e);
@@ -248,5 +246,5 @@
     #region Control Events
     private void cloneAlgorithmButton_Click(object sender, EventArgs e) {
-      MainFormManager.MainForm.ShowContent((IContent)Content.Algorithm.Clone());
+      MainFormManager.MainForm.ShowContent(Content.CloneAlgorithm());
     }
     private void refreshButton_Click(object sender, System.EventArgs e) {
@@ -261,5 +259,5 @@
       }
     }
-    protected virtual void newProblemButton_Click(object sender, EventArgs e) {
+    private void newProblemButton_Click(object sender, EventArgs e) {
       if (problemTypeSelectorDialog == null) {
         problemTypeSelectorDialog = new TypeSelectorDialog();
@@ -277,5 +275,5 @@
       }
     }
-    protected virtual void openProblemButton_Click(object sender, EventArgs e) {
+    private void openProblemButton_Click(object sender, EventArgs e) {
       openFileDialog.Title = "Open Problem";
       if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
@@ -308,20 +306,20 @@
       }
     }
-    protected virtual void storeAlgorithmInEachRunCheckBox_CheckedChanged(object sender, EventArgs e) {
+    private void storeAlgorithmInEachRunCheckBox_CheckedChanged(object sender, EventArgs e) {
       if (Content != null) Content.StoreAlgorithmInEachRun = storeAlgorithmInEachRunCheckBox.Checked;
     }
-    protected virtual void startButton_Click(object sender, EventArgs e) {
+    private void startButton_Click(object sender, EventArgs e) {
       Content.Start();
     }
-    protected virtual void pauseButton_Click(object sender, EventArgs e) {
+    private void pauseButton_Click(object sender, EventArgs e) {
       Content.Pause();
     }
-    protected virtual void stopButton_Click(object sender, EventArgs e) {
+    private void stopButton_Click(object sender, EventArgs e) {
       Content.Stop();
     }
-    protected virtual void resetButton_Click(object sender, EventArgs e) {
+    private void resetButton_Click(object sender, EventArgs e) {
       Content.Prepare(false);
     }
-    protected virtual void problemTabPage_DragEnterOver(object sender, DragEventArgs e) {
+    private void problemTabPage_DragEnterOver(object sender, DragEventArgs e) {
       e.Effect = DragDropEffects.None;
       Type type = e.Data.GetData("Type") as Type;
@@ -334,5 +332,5 @@
       }
     }
-    protected virtual void problemTabPage_DragDrop(object sender, DragEventArgs e) {
+    private void problemTabPage_DragDrop(object sender, DragEventArgs e) {
       if (e.Effect != DragDropEffects.None) {
         IProblem problem = e.Data.GetData("Value") as IProblem;
Index: branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBProblemView.cs
===================================================================
--- branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBProblemView.cs	(revision 5666)
+++ branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBProblemView.cs	(revision 5667)
@@ -30,5 +30,5 @@
   [View("OKBProblem View")]
   [Content(typeof(OKBProblem), true)]
-  public partial class OKBProblemView : NamedItemView {
+  public sealed partial class OKBProblemView : NamedItemView {
     public new OKBProblem Content {
       get { return (OKBProblem)base.Content; }
@@ -70,5 +70,5 @@
       base.SetEnabledStateOfControls();
       problemComboBox.Enabled = (Content != null) && !ReadOnly && !Locked && (problemComboBox.Items.Count > 0);
-      cloneProblemButton.Enabled = (Content != null) && (Content.Problem != null) && !ReadOnly && !Locked;
+      cloneProblemButton.Enabled = (Content != null) && (Content.ProblemId != -1) && !ReadOnly && !Locked;
       refreshButton.Enabled = (Content != null) && !ReadOnly && !Locked;
       parameterCollectionView.Enabled = Content != null;
@@ -86,5 +86,5 @@
       } else {
         Cursor = Cursors.AppStarting;
-        problemComboBox.Enabled = refreshButton.Enabled = false;
+        problemComboBox.Enabled = cloneProblemButton.Enabled = refreshButton.Enabled = parameterCollectionView.Enabled = false;
       }
     }
@@ -103,7 +103,6 @@
       if (InvokeRequired)
         Invoke(new EventHandler(Content_ProblemChanged), sender, e);
-      else {
-        problemComboBox.SelectedItem = RunCreationClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
-      }
+      else
+        OnContentChanged();
     }
     #endregion
@@ -111,5 +110,5 @@
     #region Control Events
     private void cloneProblemButton_Click(object sender, EventArgs e) {
-      MainFormManager.MainForm.ShowContent((IContent)Content.Problem.Clone());
+      MainFormManager.MainForm.ShowContent(Content.CloneProblem());
     }
     private void refreshButton_Click(object sender, System.EventArgs e) {
