Index: branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/FactorVariable.cs
===================================================================
--- branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/FactorVariable.cs	(revision 14554)
+++ branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/FactorVariable.cs	(revision 14717)
@@ -31,13 +31,13 @@
   [Item("FactorVariable", "Represents a categorical variable (comparable to factors as in R).")]
   public class FactorVariable : VariableBase {
-    private readonly Dictionary<string, List<string>> variableValues;
+    private readonly Dictionary<string, Dictionary<string, int>> variableValues; // for each variable value also store a zero-based index
     [Storable]
-    public IEnumerable<KeyValuePair<string, List<string>>> VariableValues {
+    public IEnumerable<KeyValuePair<string, Dictionary<string, int>>> VariableValues {
       get { return variableValues; }
       set {
-        if (value == null) throw new ArgumentNullException();
+        if(value == null) throw new ArgumentNullException();
         variableValues.Clear();
-        foreach (var kvp in value) {
-          variableValues.Add(kvp.Key, new List<string>(kvp.Value));
+        foreach(var kvp in value) {
+          variableValues.Add(kvp.Key, new Dictionary<string, int>(kvp.Value));
         }
       }
@@ -47,15 +47,15 @@
     protected FactorVariable(bool deserializing)
       : base(deserializing) {
-      variableValues = new Dictionary<string, List<string>>();
+      variableValues = new Dictionary<string, Dictionary<string, int>>();
     }
     protected FactorVariable(FactorVariable original, Cloner cloner)
       : base(original, cloner) {
       variableValues =
-        original.variableValues.ToDictionary(kvp => kvp.Key, kvp => new List<string>(kvp.Value));
+        original.variableValues.ToDictionary(kvp => kvp.Key, kvp => new Dictionary<string, int>(kvp.Value));
     }
     public FactorVariable() : this("FactorVariable", "Represents a categorical variable (comparable to factors as in R).") { }
     public FactorVariable(string name, string description)
       : base(name, description) {
-      variableValues = new Dictionary<string, List<string>>();
+      variableValues = new Dictionary<string, Dictionary<string,int>>();
     }
 
@@ -69,5 +69,9 @@
 
     public IEnumerable<string> GetVariableValues(string variableName) {
-      return variableValues[variableName];
+      return variableValues[variableName].Keys;
+    }
+
+    public int GetIndexForValue(string variableName, string variableValue) {
+      return variableValues[variableName][variableValue];
     }
   }
Index: branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/FactorVariableTreeNode.cs
===================================================================
--- branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/FactorVariableTreeNode.cs	(revision 14554)
+++ branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/FactorVariableTreeNode.cs	(revision 14717)
@@ -21,4 +21,5 @@
 
 using System;
+using System.Collections.Generic;
 using System.Linq;
 using HeuristicLab.Common;
@@ -51,5 +52,5 @@
       : base(original, cloner) {
       variableName = original.variableName;
-      if (original.weights != null) {
+      if(original.weights != null) {
         this.weights = new double[original.Weights.Length];
         Array.Copy(original.Weights, weights, weights.Length);
@@ -74,7 +75,7 @@
 
     public override void ShakeLocalParameters(IRandom random, double shakingFactor) {
-      if (random.NextDouble() < 0.2) {
+      if(random.NextDouble() < 0.2) {
         VariableName = Symbol.VariableNames.SampleRandom(random);
-        if (weights.Length != Symbol.GetVariableValues(VariableName).Count()) {
+        if(weights.Length != Symbol.GetVariableValues(VariableName).Count()) {
           // if the length of the weight array does not match => re-initialize weights
           weights =
@@ -87,5 +88,5 @@
         var idx = random.Next(weights.Length);
         // 50% additive & 50% multiplicative
-        if (random.NextDouble() < 0.5) {
+        if(random.NextDouble() < 0.5) {
           double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorMu,
             Symbol.WeightManipulatorSigma);
@@ -103,12 +104,5 @@
 
     public double GetValue(string cat) {
-      // TODO: perf
-      var s = Symbol;
-      int idx = 0;
-      foreach (var val in s.GetVariableValues(VariableName)) {
-        if (cat == val) return weights[idx];
-        idx++;
-      }
-      throw new ArgumentOutOfRangeException("Found unknown value " + cat + " for variable " + VariableName);
+      return weights[Symbol.GetIndexForValue(VariableName, cat)];
     }
 
