Index: trunk/sources/HeuristicLab.CEDMA.Core/Agent.cs
===================================================================
--- trunk/sources/HeuristicLab.CEDMA.Core/Agent.cs	(revision 511)
+++ trunk/sources/HeuristicLab.CEDMA.Core/Agent.cs	(revision 512)
@@ -88,5 +88,5 @@
         return results;
       }
-    } 
+    }
 
     public IView CreateView() {
@@ -94,31 +94,41 @@
         byte[] rawData = Database.GetAgentRawData(Id);
         IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(rawData);
-        DownloadOperators(opGraph, new Dictionary<long, IOperator>());
         foreach(IOperator op in opGraph.Operators) OperatorGraph.AddOperator(op);
         OperatorGraph.InitialOperator = opGraph.InitialOperator;
+        PatchOperatorLinks(OperatorGraph);
       }
       return new AgentView(this);
     }
 
-    private void DownloadOperators(IOperatorGraph opGraph, Dictionary<long, IOperator> downloaded) {
+    private void PatchOperatorLinks(IOperatorGraph opGraph) {
       foreach(IOperator op in opGraph.Operators) {
-        DownloadOperators(op, downloaded);
+        PatchOperatorLinks(op);
       }
     }
 
-    private void DownloadOperators(IOperator op, Dictionary<long, IOperator> downloaded) {
+    private void PatchOperatorLinks(IOperator op) {
       if(op is OperatorLink) {
         OperatorLink link = op as OperatorLink;
-        if(downloaded.ContainsKey(link.Id)) {
-          link.Operator = downloaded[link.Id];
-        } else {
-          OperatorEntry targetEntry = Database.GetOperator(link.Id);
-          IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData);
-          downloaded.Add(link.Id, target);
-          DownloadOperators(target, downloaded);
-          link.Operator = target;
+        link.Database = Database;
+        //if(downloaded.ContainsKey(link.Id)) {
+        //  link.Operator = downloaded[link.Id];
+        //} else {
+        //  OperatorEntry targetEntry = Database.GetOperator(link.Id);
+        //  IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData);
+        //  downloaded.Add(link.Id, target);
+        //  PatchOperatorLinks(target, downloaded);
+        //  link.Operator = target;
+        //}
+      } else if(op is CombinedOperator) {
+        PatchOperatorLinks(((CombinedOperator)op).OperatorGraph);
+      }
+      // also patch operator links contained (indirectly) in variables
+      foreach(VariableInfo varInfo in op.VariableInfos) {
+        IVariable var = op.GetVariable(varInfo.ActualName);
+        if(var != null && var.Value is IOperatorGraph) {
+          PatchOperatorLinks((IOperatorGraph)var.Value);
+        } else if(var != null && var.Value is IOperator) {
+          PatchOperatorLinks((IOperator)var.Value);
         }
-      } else if(op is CombinedOperator) {
-        DownloadOperators(((CombinedOperator)op).OperatorGraph, downloaded);
       }
     }
Index: trunk/sources/HeuristicLab.CEDMA.Core/AgentView.cs
===================================================================
--- trunk/sources/HeuristicLab.CEDMA.Core/AgentView.cs	(revision 511)
+++ trunk/sources/HeuristicLab.CEDMA.Core/AgentView.cs	(revision 512)
@@ -32,6 +32,6 @@
 namespace HeuristicLab.CEDMA.Core {
   public partial class AgentView : ViewBase {
-    private IAgent agent;
-    public IAgent Agent {
+    private Agent agent;
+    public Agent Agent {
       get { return agent; }
       set { agent = value; }
@@ -42,5 +42,5 @@
       Caption = "Agent";
     }
-    public AgentView(IAgent agent)
+    public AgentView(Agent agent)
       : this() {
       Agent = agent;
Index: trunk/sources/HeuristicLab.CEDMA.Core/DatabaseOperatorLibrary.cs
===================================================================
--- trunk/sources/HeuristicLab.CEDMA.Core/DatabaseOperatorLibrary.cs	(revision 511)
+++ trunk/sources/HeuristicLab.CEDMA.Core/DatabaseOperatorLibrary.cs	(revision 512)
@@ -91,8 +91,14 @@
     }
 
+    private void PatchLinks(IOperatorGraph opGraph) {
+      foreach(IOperator op in opGraph.Operators) {
+        PatchLinks(op);
+      }
+    }
+
     private void PatchLinks(IOperator op) {
       if(op is OperatorLink) {
         OperatorLink link = op as OperatorLink;
-        link.Operator = FindOperator(link.Id);
+        link.Database = Database;
       }
       else if(op is CombinedOperator) {
@@ -100,4 +106,13 @@
         foreach(IOperator internalOp in combinedOp.OperatorGraph.Operators) {
           PatchLinks(internalOp);
+        }
+      }
+      // also patch operator links contained (indirectly) in variables
+      foreach(VariableInfo varInfo in op.VariableInfos) {
+        IVariable var = op.GetVariable(varInfo.ActualName);
+        if(var != null && var.Value is IOperatorGraph) {
+          PatchLinks((IOperatorGraph)var.Value);
+        } else if(var != null && var.Value is IOperator) {
+          PatchLinks((IOperator)var.Value);
         }
       }
Index: trunk/sources/HeuristicLab.CEDMA.Core/OperatorLink.cs
===================================================================
--- trunk/sources/HeuristicLab.CEDMA.Core/OperatorLink.cs	(revision 511)
+++ trunk/sources/HeuristicLab.CEDMA.Core/OperatorLink.cs	(revision 512)
@@ -26,4 +26,6 @@
 using HeuristicLab.Core;
 using System.Xml;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using HeuristicLab.Operators;
 
 namespace HeuristicLab.CEDMA.Core {
@@ -33,4 +35,6 @@
       get { return id; }
     }
+
+    public IDatabase Database { get; set; }
 
     private IOperator myOperator;
@@ -65,4 +69,11 @@
 
     public override IView CreateView() {
+      if(Operator == null) {
+        if(Database == null) return null;
+        OperatorEntry targetEntry = Database.GetOperator(Id);
+        IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData);
+        PatchOperatorLinks(target);
+        Operator = target;
+      }
       return myOperator.CreateView();
     }
@@ -84,4 +95,37 @@
       base.Populate(node, restoredObjects);
     }
+
+    private void PatchOperatorLinks(IOperatorGraph opGraph) {
+      foreach(IOperator op in opGraph.Operators) {
+        PatchOperatorLinks(op);
+      }
+    }
+
+    private void PatchOperatorLinks(IOperator op) {
+      if(op is OperatorLink) {
+        OperatorLink link = op as OperatorLink;
+        link.Database = Database;
+        //if(downloaded.ContainsKey(link.Id)) {
+        //  link.Operator = downloaded[link.Id];
+        //} else {
+        //  OperatorEntry targetEntry = Database.GetOperator(link.Id);
+        //  IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData);
+        //  downloaded.Add(link.Id, target);
+        //  PatchOperatorLinks(target, downloaded);
+        //  link.Operator = target;
+        //}
+      } else if(op is CombinedOperator) {
+        PatchOperatorLinks(((CombinedOperator)op).OperatorGraph);
+      }
+      // also patch operator links contained (indirectily) in variables
+      foreach(VariableInfo varInfo in op.VariableInfos) {
+        IVariable var = op.GetVariable(varInfo.ActualName);
+        if(var != null && var.Value is IOperatorGraph) {
+          PatchOperatorLinks((IOperatorGraph)var.Value);
+        } else if(var != null && var.Value is IOperator) {
+          PatchOperatorLinks((IOperator)var.Value);
+        }
+      }
+    }
   }
 }
