Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Console.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Console.cs	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Console.cs	(revision 1129)
@@ -75,7 +75,8 @@
     private void ResetConnection() {
       NetTcpBinding binding = new NetTcpBinding();
-      binding.MaxReceivedMessageSize = 100000000; // 100Mbytes
-      binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars
-      binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements;
+      binding.ReceiveTimeout = new TimeSpan(1, 0, 0);
+      binding.MaxReceivedMessageSize = 1000000000; // 100Mbytes
+      binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars
+      binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements;
       binding.Security.Mode = SecurityMode.None;
       factory = new ChannelFactory<IStore>(binding);
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs	(revision 1129)
@@ -41,4 +41,5 @@
     public string Name {
       get { return name; }
+      set { name = value; }
     }
 
@@ -48,7 +49,9 @@
         // lazy loading of problem from DB
         if (problem == null) {
-          var persistedData = Store.Select(new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, Ontology.AnyEntity));
+          var serializedDataVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("SerializedData");
+          var persistedData = Store.Query(
+            new Statement[] { new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, serializedDataVar)});
           if (persistedData.Count() == 1) {
-            Literal persistedLiteral = (Literal)persistedData.First().Property;
+            Literal persistedLiteral = (Literal)persistedData.First().Get("SerializedData");
             this.problem = (Problem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String((string)persistedLiteral.Value));
           } else
@@ -69,7 +72,5 @@
       Store = store;
       guid = new Guid(dataSetEntity.Uri.Remove(0, Ontology.CedmaNameSpace.Length));
-      var names = store.Select(new Statement(dataSetEntity, Ontology.PredicateName, Ontology.AnyEntity));
-      if (names.Count() > 0) name = (string)((Literal)names.First().Property).Value;
-      else name = guid.ToString();
+      name = guid.ToString();
     }
 
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetList.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetList.cs	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetList.cs	(revision 1129)
@@ -58,7 +58,16 @@
 
     private void ReloadList() {
-      var statements = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet));
-      foreach (Statement s in statements) {
-        DataSet d = new DataSet(store, s.Subject);
+      HeuristicLab.CEDMA.DB.Interfaces.Variable dataSetVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("DataSet");
+      HeuristicLab.CEDMA.DB.Interfaces.Variable dataSetNameVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("Name");
+      var bindings = store.Query(
+        "?DataSet <"+Ontology.PredicateInstanceOf.Uri+"> <"+Ontology.TypeDataSet.Uri+"> ." + Environment.NewLine +
+        "?DataSet <"+Ontology.PredicateName.Uri+"> ?Name .");
+      //  new Statement[] { 
+      //    new Statement(dataSetVar, Ontology.PredicateInstanceOf, Ontology.TypeDataSet),
+      //    new Statement(dataSetVar, Ontology.PredicateName, dataSetNameVar)
+      //});
+      foreach (var binding in bindings) {
+        DataSet d = new DataSet(store, (Entity)binding.Get("DataSet"));
+        d.Name = (string)((Literal)binding.Get("Name")).Value;
         lock (dataSetList) {
           dataSetList.Add(d);
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Results.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Results.cs	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Results.cs	(revision 1129)
@@ -74,55 +74,55 @@
       if (store == null) yield break;
 
-      var models = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity));
+      //var models = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity));
 
-      //var results = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity))
-      //   .SelectMany(x => store.Select(new SelectFilter(
-      //     new Entity[] { (Entity)x.Property },
-      //     new Entity[] { Ontology.PredicateModelAttribute },
-      //     new Resource[] { Ontology.AnyEntity })))
-      //   .SelectMany(x =>
-      //     store.Select(
-      //        new SelectFilter(
-      //        new Entity[] { (Entity)x.Property },
-      //        new Entity[] { Ontology.PredicateModelAttributeName },
-      //        new Entity[] { Ontology.AnyEntity })).Select(y =>
-      //          new {
-      //            Model = x.Subject,
-      //            Attribute = (Entity)x.Property,
-      //            AttributeName = (Literal)y.Property
-      //          }))
-      //   .SelectMany(x =>
-      //     store.Select(
-      //       new Statement(x.Attribute, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity))
-      //       .Select(y =>
-      //         new {
-      //           Model = x.Model.Uri,
-      //           AttributeName = x.AttributeName.Value,
-      //           AttributeValue = ((Literal)y.Property).Value
-      //         })).GroupBy(x => x.Model);
+      ////var results = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity))
+      ////   .SelectMany(x => store.Select(new SelectFilter(
+      ////     new Entity[] { (Entity)x.Property },
+      ////     new Entity[] { Ontology.PredicateModelAttribute },
+      ////     new Resource[] { Ontology.AnyEntity })))
+      ////   .SelectMany(x =>
+      ////     store.Select(
+      ////        new SelectFilter(
+      ////        new Entity[] { (Entity)x.Property },
+      ////        new Entity[] { Ontology.PredicateModelAttributeName },
+      ////        new Entity[] { Ontology.AnyEntity })).Select(y =>
+      ////          new {
+      ////            Model = x.Subject,
+      ////            Attribute = (Entity)x.Property,
+      ////            AttributeName = (Literal)y.Property
+      ////          }))
+      ////   .SelectMany(x =>
+      ////     store.Select(
+      ////       new Statement(x.Attribute, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity))
+      ////       .Select(y =>
+      ////         new {
+      ////           Model = x.Model.Uri,
+      ////           AttributeName = x.AttributeName.Value,
+      ////           AttributeValue = ((Literal)y.Property).Value
+      ////         })).GroupBy(x => x.Model);
 
-      entries = new List<ResultsEntry>();
-      foreach (var model in models) {
-        var attributes = store.Select(new Statement((Entity)model.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity));
+      //entries = new List<ResultsEntry>();
+      //foreach (var model in models) {
+      //  var attributes = store.Select(new Statement((Entity)model.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity));
 
-        foreach (var attr in attributes) {
-          var namesAndValues = store
-            .Select(new SelectFilter(new Entity[] { (Entity)attr.Property },
-              new Entity[] { Ontology.PredicateModelAttributeName, Ontology.PredicateModelAttributeValue },
-              new Entity[] { Ontology.AnyEntity }));
-        }
-      }
+      //  foreach (var attr in attributes) {
+      //    var namesAndValues = store
+      //      .Select(new SelectFilter(new Entity[] { (Entity)attr.Property },
+      //        new Entity[] { Ontology.PredicateModelAttributeName, Ontology.PredicateModelAttributeValue },
+      //        new Entity[] { Ontology.AnyEntity }));
+      //  }
+      //}
 
-      foreach (var row in results) {
-        ResultsEntry entry = new ResultsEntry(row.First().Model);
-        foreach (var attr in row) {
-          entry.Set((string)attr.AttributeName, attr.AttributeValue);
-        }
-        entries.Add(entry);
-        yield return entry;
-      }
+      //foreach (var row in results) {
+      //  ResultsEntry entry = new ResultsEntry(row.First().Model);
+      //  foreach (var attr in row) {
+      //    entry.Set((string)attr.AttributeName, attr.AttributeValue);
+      //  }
+      //  entries.Add(entry);
+      //  yield return entry;
+      //}
 
-      FireChanged();
-      cached = true;
+      //FireChanged();
+      //cached = true;
     }
 
@@ -130,11 +130,11 @@
       if (store == null) yield break;
 
-      var attributeNames =
-        store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateModelAttributeName, Ontology.AnyEntity))
-        .Select(s => (string)((Literal)s.Property).Value)        
-        .Distinct();
-      foreach (var name in attributeNames) {
-        yield return name;
-      }
+      //var attributeNames =
+      //  store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateModelAttributeName, Ontology.AnyEntity))
+      //  .Select(s => (string)((Literal)s.Property).Value)        
+      //  .Distinct();
+      //foreach (var name in attributeNames) {
+      //  yield return name;
+      //}
     }
   }
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/HeuristicLab.CEDMA.DB.Interfaces.csproj
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/HeuristicLab.CEDMA.DB.Interfaces.csproj	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/HeuristicLab.CEDMA.DB.Interfaces.csproj	(revision 1129)
@@ -70,5 +70,5 @@
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="IVariableBindings.cs" />
+    <Compile Include="Variable.cs" />
     <Compile Include="Ontology.cs" />
     <Compile Include="SelectFilter.cs" />
@@ -82,4 +82,5 @@
     <Compile Include="HeuristicLabCedmaDbInterfacesPlugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="VariableBindings.cs" />
   </ItemGroup>
   <ItemGroup>
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/IStore.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/IStore.cs	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/IStore.cs	(revision 1129)
@@ -35,5 +35,8 @@
 
     [OperationContract]
-    ICollection<IVariableBindings> Select(ICollection<Statement> query);
+    ICollection<VariableBindings> Query(ICollection<Statement> query);
+
+    [OperationContract(Name="QueryN3")]
+    ICollection<VariableBindings> Query(string query);
   }
 }
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/IVariableBindings.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/IVariableBindings.cs	(revision 1116)
+++ 	(revision )
@@ -1,33 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ServiceModel;
-using System.Data;
-using System.Linq.Expressions;
-
-namespace HeuristicLab.CEDMA.DB.Interfaces {
-  public interface IVariableBindings : IEnumerable<KeyValuePair<string, object>> {
-  }
-}
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/Statement.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/Statement.cs	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/Statement.cs	(revision 1129)
@@ -32,4 +32,5 @@
   [KnownType(typeof(Entity))]
   [KnownType(typeof(SerializedLiteral))]
+  [KnownType(typeof(Variable))]
   public class Statement {
     [DataMember]
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/Variable.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/Variable.cs	(revision 1129)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/Variable.cs	(revision 1129)
@@ -0,0 +1,50 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using System.Runtime.Serialization;
+
+namespace HeuristicLab.CEDMA.DB.Interfaces {
+  [DataContract]
+  public class Variable: Entity {
+    [DataMember]
+    public string Name { get; set; }
+
+    public Variable(string name) : base(name) {
+      this.Name = name;
+    }
+
+    public override bool Equals(object obj) {
+      if(this == obj) return true;
+      Variable other = obj as Variable;
+      if(obj == null) return false;
+      else return other.Name.Equals(this.Name);
+    }
+
+    public override int GetHashCode() {
+      return Name.GetHashCode();
+    }
+  }
+}
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/VariableBindings.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/VariableBindings.cs	(revision 1129)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB.Interfaces/VariableBindings.cs	(revision 1129)
@@ -0,0 +1,73 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.CEDMA.DB.Interfaces;
+using System.ServiceModel;
+using System.Data;
+using System.Data.Common;
+using System.Threading;
+using System.Xml;
+using System.IO;
+using System.Runtime.Serialization;
+
+namespace HeuristicLab.CEDMA.DB.Interfaces {
+  [DataContract]
+  [KnownType(typeof(Literal))]
+  [KnownType(typeof(Entity))]
+  [KnownType(typeof(SerializedLiteral))]
+  public class VariableBindings : IEnumerable<KeyValuePair<string,object>> {
+
+    [DataMember]
+    private Dictionary<string,object> bindings;
+
+    public VariableBindings() {
+      bindings = new Dictionary<string, object>();
+    }
+
+    public void Add(string name, object value) {
+      bindings.Add(name, value);
+    }
+
+    public object Get(string name) {
+      return bindings[name];
+    }
+
+    #region IEnumerable<KeyValuePair<string,object>> Members
+
+    public IEnumerator<KeyValuePair<string, object>> GetEnumerator() {
+      return bindings.GetEnumerator();
+    }
+
+    #endregion
+
+    #region IEnumerable Members
+
+    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
+      return GetEnumerator();
+    }
+
+    #endregion
+  }
+}
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/HeuristicLab.CEDMA.DB.csproj
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/HeuristicLab.CEDMA.DB.csproj	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/HeuristicLab.CEDMA.DB.csproj	(revision 1129)
@@ -74,5 +74,4 @@
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="VariableBindings.cs" />
     <Compile Include="Store.cs" />
     <Compile Include="HeuristicLabCedmaDbPlugin.cs" />
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/Store.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/Store.cs	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/Store.cs	(revision 1129)
@@ -54,6 +54,15 @@
     }
 
-    public ICollection<IVariableBindings> Select(ICollection<Statement> query) {
-      SemWeb.Query.QueryResultSink resultSink = new MyQueryResultSink();
+
+    public ICollection<VariableBindings> Query(string query) {
+      MyQueryResultSink resultSink = new MyQueryResultSink();
+      SemWeb.N3Reader n3Reader = new SemWeb.N3Reader(new StringReader(query));
+      SemWeb.Query.GraphMatch matcher = new SemWeb.Query.GraphMatch(n3Reader);
+      matcher.Run(store, resultSink);
+      return resultSink.Bindings;
+    }
+
+    public ICollection<VariableBindings> Query(ICollection<Statement> query) {
+      MyQueryResultSink resultSink = new MyQueryResultSink();
       Translate(query).Run(store, resultSink);
       return resultSink.Bindings;
@@ -61,9 +70,8 @@
 
     private SemWeb.Query.Query Translate(ICollection<Statement> query) {
-      SemWeb.Query.GraphMatch graphMatch = new SemWeb.Query.GraphMatch();
-      foreach(Statement statement in query) {
-        graphMatch.AddGraphStatement(Translate(statement));
-      }
-      return graphMatch;
+      Dictionary<object, object> translatedObjects = new Dictionary<object, object>();
+      SemWeb.MemoryStore queryStore = new SemWeb.MemoryStore(query.Select(st => Translate(st, translatedObjects)).ToArray());
+
+      return new SemWeb.Query.GraphMatch(queryStore);
     }
 
@@ -85,17 +93,17 @@
     //}
 
-    private SemWeb.SelectFilter Translate(SelectFilter filter) {
-      SemWeb.SelectFilter f = new SemWeb.SelectFilter();
-      f.Subjects = Array.ConvertAll(filter.Subjects, s => Translate(s));
-      f.Predicates = Array.ConvertAll(filter.Predicates, p => Translate(p));
-      f.Objects = Array.ConvertAll(filter.Properties, prop => Translate(prop));
-      return f;
-    }
-
-    private SemWeb.Entity Translate(Entity e) {
+    //private SemWeb.SelectFilter Translate(SelectFilter filter) {
+    //  SemWeb.SelectFilter f = new SemWeb.SelectFilter();
+    //  f.Subjects = Array.ConvertAll(filter.Subjects, s => Translate(s));
+    //  f.Predicates = Array.ConvertAll(filter.Predicates, p => Translate(p));
+    //  f.Objects = Array.ConvertAll(filter.Properties, prop => Translate(prop));
+    //  return f;
+    //}
+
+    private static SemWeb.Entity Translate(Entity e) {
       return e.Uri == null ? null : new SemWeb.Entity(e.Uri);
     }
 
-    private SemWeb.Resource Translate(Resource prop) {
+    private static SemWeb.Resource Translate(Resource prop) {
       if (prop is Literal) {
         return TranslateLiteral((Literal)prop);
@@ -107,31 +115,64 @@
     }
 
-    private Statement Translate(SemWeb.Statement statement) {
-      if (statement.Object is SemWeb.Literal) {
-        return new Statement(
-          new Entity(statement.Subject.Uri),
-          new Entity(statement.Predicate.Uri),
-          TranslateLiteral((SemWeb.Literal)statement.Object));
-      } else {
-        return new Statement(
-          new Entity(statement.Subject.Uri),
-          new Entity(statement.Predicate.Uri),
-          new Entity(((SemWeb.Entity)statement.Object).Uri));
-      }
-    }
-
-    private SemWeb.Statement Translate(Statement statement) {
+    private static Statement Translate(SemWeb.Statement statement) {
+      return Translate(statement, new Dictionary<object, object>());
+    }
+
+    private static Statement Translate(SemWeb.Statement statement, Dictionary<object, object> translatedObjects) {
+      if (!translatedObjects.ContainsKey(statement.Subject)) {
+        translatedObjects[statement.Subject] = new Entity(statement.Subject.Uri);
+      }
+      if (!translatedObjects.ContainsKey(statement.Predicate)) {
+        translatedObjects[statement.Predicate] = new Entity(statement.Predicate.Uri);
+      }
+      if (!translatedObjects.ContainsKey(statement.Object)) {
+        if (statement.Object is SemWeb.Literal) {
+          translatedObjects[statement.Object] = TranslateLiteral((SemWeb.Literal)statement.Object);
+        } else {
+          translatedObjects[statement.Object] = new Entity(((SemWeb.Entity)statement.Object).Uri);
+        }
+      }
+
+      Entity subjectEntity = (Entity)translatedObjects[statement.Subject];
+      Entity predicateEntity = (Entity)translatedObjects[statement.Predicate];
+      Resource property = (Resource)translatedObjects[statement.Object];
+
+      return new Statement(
+        subjectEntity,
+        predicateEntity,
+        property);
+    }
+
+    private static SemWeb.Statement Translate(Statement statement) {
+      return Translate(statement, new Dictionary<object, object>());
+    }
+
+    private static SemWeb.Statement Translate(Statement statement, Dictionary<object, object> translatedObjects) {
+      if (!translatedObjects.ContainsKey(statement.Subject)) {
+        translatedObjects[statement.Subject] = Translate(statement.Subject);
+      }
+      if (!translatedObjects.ContainsKey(statement.Predicate)) {
+        translatedObjects[statement.Predicate] = Translate(statement.Predicate);
+      }
+      if (!translatedObjects.ContainsKey(statement.Property)) {
+        translatedObjects[statement.Property] = Translate(statement.Property);
+      }
+
+      SemWeb.Entity subject = (SemWeb.Entity)translatedObjects[statement.Subject];
+      SemWeb.Entity predicate = (SemWeb.Entity)translatedObjects[statement.Predicate];
+      SemWeb.Resource property = (SemWeb.Resource)translatedObjects[statement.Property];
+
       return new SemWeb.Statement(
-        Translate(statement.Subject),
-        Translate(statement.Predicate),
-        Translate(statement.Property));
-    }
-
-    private SemWeb.Literal TranslateLiteral(SerializedLiteral l) {
+        subject,
+        predicate,
+        property);
+    }
+
+    private static SemWeb.Literal TranslateLiteral(SerializedLiteral l) {
       if (l.RawData == null) return null;
       return new SemWeb.Literal(l.RawData, null, "serializedItem");
     }
 
-    private SemWeb.Literal TranslateLiteral(Literal l) {
+    private static SemWeb.Literal TranslateLiteral(Literal l) {
       if (l.Value == null) return null;
       if (l.Value is double) return SemWeb.Literal.FromValue((double)l.Value);
@@ -143,5 +184,5 @@
     }
 
-    private Resource TranslateLiteral(SemWeb.Literal l) {
+    private static Resource TranslateLiteral(SemWeb.Literal l) {
       if (l.DataType == "serializedItem") {
         return new SerializedLiteral(l.Value);
@@ -152,4 +193,27 @@
       }
     }
+
+    private class MyQueryResultSink : SemWeb.Query.QueryResultSink {
+
+      private List<VariableBindings> bindings = new List<VariableBindings>();
+      public ICollection<VariableBindings> Bindings {
+        get { return bindings.AsReadOnly(); }
+      }
+
+      public override bool Add(SemWeb.Query.VariableBindings result) {
+        VariableBindings varBindings = new VariableBindings();
+        foreach (SemWeb.Variable var in result.Variables) {
+          if (var.LocalName != null && result[var] != null) {
+            if (result[var] is SemWeb.Literal) {
+              varBindings.Add(var.LocalName, TranslateLiteral((SemWeb.Literal)result[var]));
+            } else {
+              varBindings.Add(var.LocalName, new Entity(((SemWeb.Entity)result[var]).Uri));
+            }
+          }
+          bindings.Add(varBindings);
+        }
+        return true;
+      }
+    }
   }
 }
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/VariableBindings.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.DB/VariableBindings.cs	(revision 1116)
+++ 	(revision )
@@ -1,63 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Data.Linq;
-using HeuristicLab.CEDMA.DB.Interfaces;
-using System.ServiceModel;
-using System.Data;
-using System.Data.Common;
-using System.Threading;
-using HeuristicLab.Data;
-using HeuristicLab.Core;
-using System.Xml;
-using System.IO;
-
-namespace HeuristicLab.CEDMA.DB {
-  [Serializable]
-  public class VariableBindings : IVariableBindings {
-
-    private List<KeyValuePair<string, object>> bindings;
-
-    public VariableBindings() {
-      bindings = new List<KeyValuePair<string, object>>();
-    }
-
-    #region IEnumerable<KeyValuePair<string,object>> Members
-
-    public IEnumerator<KeyValuePair<string, object>> GetEnumerator() {
-      return bindings.GetEnumerator();
-    }
-
-    #endregion
-
-    #region IEnumerable Members
-
-    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
-      return GetEnumerator();
-    }
-
-    #endregion
-  }
-}
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Dispatcher.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Dispatcher.cs	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Dispatcher.cs	(revision 1129)
@@ -51,36 +51,36 @@
 
     private void FillDispatchQueue() {
-      Dictionary<Entity, Dictionary<int, int>> numberOfModelsOfTargetVariableOfDataSet = new Dictionary<Entity, Dictionary<int, int>>();
-      var datasetStatements = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet));
-      foreach (Statement datasetStatement in datasetStatements) {
-        numberOfModelsOfTargetVariableOfDataSet.Add(datasetStatement.Subject, new Dictionary<int, int>());
-        var modelStatements = store.Select(new Statement(datasetStatement.Subject, Ontology.PredicateHasModel, Ontology.AnyEntity));
-        foreach (Statement modelStatement in modelStatements) {
-          var modelAttributeStatements = store.Select(new Statement((Entity)modelStatement.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity));
-          foreach (Statement modelAttrStatement in modelAttributeStatements) {
-            var targetVariableStatements = store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeName, Ontology.AnyEntity))
-               .Where(t => (string)((Literal)t.Property).Value == "TargetVariable")
-               .SelectMany(t => store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity)))
-               .GroupBy(t => (int)((Literal)t.Property).Value);
-            foreach (var targetVariable in targetVariableStatements) {
-              if (numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject].ContainsKey(targetVariable.Key)) {
-                numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject][targetVariable.Key] = targetVariable.Count();
-              } else {
-                numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject].Add(targetVariable.Key, targetVariable.Count());
-              }
-            }
-          }
-        }
-      }
-      foreach (KeyValuePair<Entity, Dictionary<int, int>> dataSetEntry in numberOfModelsOfTargetVariableOfDataSet) {
-        DataSet dataSet = new DataSet(store, dataSetEntry.Key);
-        foreach (int targetVariable in dataSet.Problem.AllowedTargetVariables)
-          if (!dataSetEntry.Value.ContainsKey(targetVariable) || dataSetEntry.Value[targetVariable] < 10) {
-            IEngine engine = CreateEngine(dataSet.Problem, targetVariable);
-            if (engine != null) {
-              QueueJob(new Execution(dataSetEntry.Key, engine, targetVariable));
-            }
-          }
-      }
+      //Dictionary<Entity, Dictionary<int, int>> numberOfModelsOfTargetVariableOfDataSet = new Dictionary<Entity, Dictionary<int, int>>();
+      //var datasetStatements = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet));
+      //foreach (Statement datasetStatement in datasetStatements) {
+      //  numberOfModelsOfTargetVariableOfDataSet.Add(datasetStatement.Subject, new Dictionary<int, int>());
+      //  var modelStatements = store.Select(new Statement(datasetStatement.Subject, Ontology.PredicateHasModel, Ontology.AnyEntity));
+      //  foreach (Statement modelStatement in modelStatements) {
+      //    var modelAttributeStatements = store.Select(new Statement((Entity)modelStatement.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity));
+      //    foreach (Statement modelAttrStatement in modelAttributeStatements) {
+      //      var targetVariableStatements = store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeName, Ontology.AnyEntity))
+      //         .Where(t => (string)((Literal)t.Property).Value == "TargetVariable")
+      //         .SelectMany(t => store.Select(new Statement((Entity)modelAttrStatement.Property, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity)))
+      //         .GroupBy(t => (int)((Literal)t.Property).Value);
+      //      foreach (var targetVariable in targetVariableStatements) {
+      //        if (numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject].ContainsKey(targetVariable.Key)) {
+      //          numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject][targetVariable.Key] = targetVariable.Count();
+      //        } else {
+      //          numberOfModelsOfTargetVariableOfDataSet[datasetStatement.Subject].Add(targetVariable.Key, targetVariable.Count());
+      //        }
+      //      }
+      //    }
+      //  }
+      //}
+      //foreach (KeyValuePair<Entity, Dictionary<int, int>> dataSetEntry in numberOfModelsOfTargetVariableOfDataSet) {
+      //  DataSet dataSet = new DataSet(store, dataSetEntry.Key);
+      //  foreach (int targetVariable in dataSet.Problem.AllowedTargetVariables)
+      //    if (!dataSetEntry.Value.ContainsKey(targetVariable) || dataSetEntry.Value[targetVariable] < 10) {
+      //      IEngine engine = CreateEngine(dataSet.Problem, targetVariable);
+      //      if (engine != null) {
+      //        QueueJob(new Execution(dataSetEntry.Key, engine, targetVariable));
+      //      }
+      //    }
+      //}
     }
 
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Server.cs
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Server.cs	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Server/Server.cs	(revision 1129)
@@ -71,7 +71,8 @@
       try {
         NetTcpBinding binding = new NetTcpBinding();
-        binding.MaxReceivedMessageSize = 100000000; // 100Mbytes
-        binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars
-        binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements;
+        binding.SendTimeout = new TimeSpan(1, 0, 0);
+        binding.MaxReceivedMessageSize = 1000000000; // 100Mbytes
+        binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars
+        binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements;
         binding.Security.Mode = SecurityMode.None;
 
Index: branches/CEDMA-Refactoring-Ticket419/HeuristicLab/app.config
===================================================================
--- branches/CEDMA-Refactoring-Ticket419/HeuristicLab/app.config	(revision 1116)
+++ branches/CEDMA-Refactoring-Ticket419/HeuristicLab/app.config	(revision 1129)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <configuration>
-    <configSections>
-        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
-            <section name="HeuristicLab.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
-        </sectionGroup>
-    </configSections>
+  <configSections>
+    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+      <section name="HeuristicLab.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+    </sectionGroup>
+  </configSections>
   <system.data>
     <DbProviderFactories>
@@ -23,3 +23,25 @@
     </HeuristicLab.Properties.Settings>
   </applicationSettings>
+  <system.diagnostics>
+    <sources>
+      <source name="System.ServiceModel"
+              switchValue="Information, ActivityTracing"
+              propagateActivity="true">
+        <listeners>
+          <add name="traceListener"
+              type="System.Diagnostics.XmlWriterTraceListener"
+              initializeData= "c:\log\Traces.svclog" />
+        </listeners>
+
+      </source>
+      <source name="System.Runtime.Serialization">
+        <listeners>
+          <add name="traceListener"
+              type="System.Diagnostics.XmlWriterTraceListener"
+              initializeData= "c:\log\Traces1.svclog" />
+        </listeners>
+      </source>
+    </sources>
+
+  </system.diagnostics>
 </configuration>
