Index: /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonDateTimeFilterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonDateTimeFilterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonDateTimeFilterView.cs	(revision 18175)
@@ -52,9 +52,11 @@
 
     private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         label.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.Value.ToString();
         label.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonDoubleFilterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonDoubleFilterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonDoubleFilterView.cs	(revision 18175)
@@ -51,9 +51,11 @@
 
     private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         label.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.Value.ToString();
         label.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonFloatFilterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonFloatFilterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonFloatFilterView.cs	(revision 18175)
@@ -51,9 +51,11 @@
 
     private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         label.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.Value.ToString();
         label.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonIntFilterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonIntFilterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonIntFilterView.cs	(revision 18175)
@@ -51,9 +51,11 @@
 
     private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         label.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.Value.ToString();
         label.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonLongFilterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonLongFilterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonLongFilterView.cs	(revision 18175)
@@ -51,9 +51,11 @@
 
     private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         label.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.Value.ToString();
         label.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonPercentFilterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonPercentFilterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonPercentFilterView.cs	(revision 18175)
@@ -58,9 +58,11 @@
 
     private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         label.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.Value.ToString();
         label.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonTimeSpanFilterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonTimeSpanFilterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonTimeSpanFilterView.cs	(revision 18175)
@@ -59,9 +59,11 @@
 
     private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         label.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.Value.ToString();
         label.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/StringComparisonAvailableValuesFilterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/StringComparisonAvailableValuesFilterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/StringComparisonAvailableValuesFilterView.cs	(revision 18175)
@@ -82,9 +82,11 @@
 
     private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         label.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueComboBox.Text = Content.Value;
         label.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/StringComparisonFilterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/StringComparisonFilterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/StringComparisonFilterView.cs	(revision 18175)
@@ -82,9 +82,11 @@
 
     private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         label.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.Value;
         label.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Core.Views/3.3/NamedItemView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Core.Views/3.3/NamedItemView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Core.Views/3.3/NamedItemView.cs	(revision 18175)
@@ -119,9 +119,11 @@
     }
     protected virtual void nameTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         nameLabel.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         nameTextBox.Text = Content.Name;
         nameLabel.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs	(revision 18175)
@@ -156,9 +156,11 @@
     }
     private void lengthTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
+      if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) {
         lengthLabel.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         lengthTextBox.Text = Content.Length.ToString();
         lengthLabel.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
@@ -249,5 +251,5 @@
         clipboardText = clipboardText.Remove(clipboardText.Length - Environment.NewLine.Length);  //remove last newline constant
 
-      var lines = clipboardText.Split(new [] { Environment.NewLine }, StringSplitOptions.None);
+      var lines = clipboardText.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
       var tabSep = new[] { '\t' };
       if (lines.Length > 2) {
Index: /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs	(revision 18175)
@@ -227,9 +227,11 @@
     }
     private void rowsTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
+      if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) {
         rowsLabel.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         rowsTextBox.Text = Content.Rows.ToString();
         rowsLabel.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
@@ -249,9 +251,11 @@
     }
     private void columnsTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
+      if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) {
         columnsLabel.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         columnsTextBox.Text = Content.Columns.ToString();
         columnsLabel.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs	(revision 18175)
@@ -86,10 +86,11 @@
 
     protected virtual void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         valueLabel.Select();  // select label to validate data
-
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.GetValue();
         valueLabel.Select();  // select label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/TextValueView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/TextValueView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Data.Views/3.3/TextValueView.cs	(revision 18175)
@@ -86,10 +86,11 @@
 
     protected virtual void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if (e.Shift && (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return))
+      if (e.Shift && (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)) {
         valueLabel.Select();  // select label to validate data
-
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         valueTextBox.Text = Content.GetValue();
         valueLabel.Select();  // select label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs	(revision 18175)
@@ -70,10 +70,11 @@
     #region control event handlers
     private void initialFrequencyTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         initialFrequencyLabel.Select();  // select label to validate data
-
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else  if (e.KeyCode == Keys.Escape) {
         initialFrequencyTextBox.Text = Content.InitialFrequency.ToString();
         initialFrequencyLabel.Select();  // select label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingOperator.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingOperator.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingOperator.cs	(revision 18175)
@@ -31,5 +31,5 @@
 namespace HeuristicLab.Optimization {
   [StorableType("43619638-9D00-4951-8138-8CCD0786E784")]
-  public abstract class MultiEncodingOperator<T> : Operator, IMultiEncodingOperator where T : class,IOperator {
+  public abstract class MultiEncodingOperator<T> : Operator, IMultiEncodingOperator where T : class, IOperator {
     private List<IEncoding> encodings = new List<IEncoding>();
     [Storable(Name = "Encodings")]
@@ -71,5 +71,6 @@
 
     public override IOperation Apply() {
-      var operations = Parameters.Select(p => p.ActualValue).OfType<IOperator>().Select(op => ExecutionContext.CreateChildOperation(op));
+      var operators = Parameters.OrderBy(p => p.Name).Select(p => p.ActualValue).OfType<IOperator>();
+      var operations = operators.Select(op => ExecutionContext.CreateChildOperation(op));
       return new OperationCollection(operations);
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Parameters.Views/3.3/ScopeTreeLookupParameterView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Parameters.Views/3.3/ScopeTreeLookupParameterView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Parameters.Views/3.3/ScopeTreeLookupParameterView.cs	(revision 18175)
@@ -106,9 +106,11 @@
     }
     protected virtual void depthTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         depthLabel.Focus();  // set focus on label to validate data
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         depthTextBox.Text = Content.Depth.ToString();
         depthLabel.Focus();  // set focus on label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs	(revision 18175)
@@ -151,4 +151,10 @@
     }
 
+    protected override IItem GetActualValue() {
+      if (ExecutionContext == null)
+        return Value;
+      return base.GetActualValue();
+    }
+
     public override string ToString() {
       if (Value != null)
Index: /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs	(revision 18175)
@@ -158,4 +158,6 @@
           var newExponent = (NumberTreeNode)numberSy.CreateTreeNode();
           newExponent.Value = ((NumberTreeNode)newPower.GetSubtree(1)).Value - 1;
+          newPower.RemoveSubtree(1);
+          newPower.AddSubtree(newExponent);
           return Product(Product(CreateNumber(exponent.Value), newPower), Derive(f, variableName));
         } else throw new NotSupportedException("Cannot derive non-integer powers");
Index: /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs	(revision 18175)
@@ -37,7 +37,12 @@
         var token = GetToken(node.Symbol);
         // operators
-        if (token == "+" || token == "-" || token == "OR" || token == "XOR" ||
-            token == "*" || token == "/" || token == "AND") {
-          strBuilder.Append("(");
+        if (token == "+" || token == "-" || token == "OR" || token == "XOR") {
+          var parenthesisRequired = false;
+          if (node.Parent != null && node.Parent.SubtreeCount > 1) {
+            var parentOp = GetToken(node.Parent.Symbol);
+            if (parentOp != "+" && parentOp != "-" && parentOp != "OR" && parentOp != "XOR")
+              parenthesisRequired = true;
+          }
+          if (parenthesisRequired) strBuilder.Append("(");
           FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString, parameters);
 
@@ -47,12 +52,25 @@
           }
 
-          strBuilder.Append(")");
+          if (parenthesisRequired) strBuilder.Append(")");
+        } else if (token == "*" || token == "/" || token == "AND") {
+          FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString, parameters);
+
+          foreach (var subtree in node.Subtrees.Skip(1)) {
+            strBuilder.Append(" ").Append(token).Append(" ");
+            // a / b * c => a / (b * C)
+            if (subtree.SubtreeCount > 1 && token == "/" && GetToken(subtree.Symbol) == "*") {
+              strBuilder.Append("(");
+              FormatRecursively(subtree, strBuilder, numberFormat, formatString, parameters);
+              strBuilder.Append(")");
+            } else {
+              FormatRecursively(subtree, strBuilder, numberFormat, formatString, parameters);
+            }
+          }
         } else if (token == "^") {
           // handle integer powers directly
-          strBuilder.Append("(");
           FormatRecursively(node.Subtrees.First(), strBuilder, numberFormat, formatString, parameters);
 
           var power = node.GetSubtree(1);
-          if(power is INumericTreeNode numNode && Math.Truncate(numNode.Value) == numNode.Value) {
+          if (power is INumericTreeNode numNode && Math.Truncate(numNode.Value) == numNode.Value) {
             strBuilder.Append(" ").Append(token).Append(" ").Append(numNode.Value.ToString(formatString, numberFormat));
           } else {
@@ -60,6 +78,4 @@
             FormatRecursively(power, strBuilder, numberFormat, formatString, parameters);
           }
-
-          strBuilder.Append(")");
         } else {
           // function with multiple arguments
@@ -76,7 +92,6 @@
         var token = GetToken(node.Symbol);
         if (token == "-" || token == "NOT") {
-          strBuilder.Append("(").Append(token).Append("(");
-          FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString, parameters);
-          strBuilder.Append("))");
+          strBuilder.Append(token);
+          FormatRecursively(node.GetSubtree(0), strBuilder, numberFormat, formatString, parameters);
         } else if (token == "/") {
           strBuilder.Append("1/");
@@ -95,5 +110,4 @@
           var varNode = node as LaggedVariableTreeNode;
           if (!varNode.Weight.IsAlmost(1.0)) {
-            strBuilder.Append("(");
             AppendNumber(strBuilder, parameters, varNode.Weight, formatString, numberFormat);
             strBuilder.Append("*");
@@ -105,16 +119,11 @@
                     .AppendFormat(numberFormat, "{0}", varNode.Lag)
                     .Append(")");
-          if (!varNode.Weight.IsAlmost(1.0)) strBuilder.Append(")");
         } else if (node.Symbol is Variable) {
           var varNode = node as VariableTreeNode;
           if (!varNode.Weight.IsAlmost(1.0)) {
-            strBuilder.Append("(");
             AppendNumber(strBuilder, parameters, varNode.Weight, formatString, numberFormat);
             strBuilder.Append("*");
           }
-
           AppendVariableName(strBuilder, varNode.VariableName);
-
-          if (!varNode.Weight.IsAlmost(1.0)) strBuilder.Append(")");
         } else if (node.Symbol is FactorVariable) {
           var factorNode = node as FactorVariableTreeNode;
@@ -130,20 +139,14 @@
           var factorNode = node as BinaryFactorVariableTreeNode;
           if (!factorNode.Weight.IsAlmost(1.0)) {
-            strBuilder.Append("(");
             AppendNumber(strBuilder, parameters, factorNode.Weight, formatString, numberFormat);
-
             strBuilder.Append("*");
           }
-
           AppendVariableName(strBuilder, factorNode.VariableName);
           strBuilder.Append(" = ");
           AppendVariableName(strBuilder, factorNode.VariableValue);
-
-          if (!factorNode.Weight.IsAlmost(1.0)) strBuilder.Append(")");
         } else if (node is INumericTreeNode numNode) {
           if (parameters == null && numNode.Value < 0) {
             // negative value
-            strBuilder.Append("(").Append(numNode.Value.ToString(formatString, numberFormat))
-                      .Append(")"); 
+            strBuilder.Append(numNode.Value.ToString(formatString, numberFormat));
           } else {
             AppendNumber(strBuilder, parameters, numNode.Value, formatString, numberFormat);
Index: /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs	(revision 18175)
@@ -40,5 +40,5 @@
   /// 
   /// S             = Expr EOF
-  /// Expr          = ['-' | '+'] Term { '+' Term | '-' Term }
+  /// Expr          = Term { '+' Term | '-' Term }
   /// Term          = Fact { '*' Fact | '/' Fact }
   /// Fact          = SimpleFact [ '^' SimpleFact ]
@@ -49,7 +49,8 @@
   ///                 | VarExpr
   ///                 | number
+  ///                 | ['+' | '-'] SimpleFact
   /// ArgList       = Expr { ',' Expr }
   /// VarExpr       = varId OptFactorPart
-  /// OptFactorPart = [ ('=' varVal | '[' ['+' | '-' ] number {',' ['+' | '-' ] number } ']' ) ]
+  /// OptFactorPart = [ ('=' varVal | '[' ['+' | '-' ]  number {',' ['+' | '-' ]  number } ']' ) ]
   /// varId         =  ident | ' ident ' | " ident "
   /// varVal        =  ident | ' ident ' | " ident "
@@ -83,5 +84,5 @@
 
     private Number number = new Number();
-    private Constant constant = new Constant();
+    private Constant minusOne = new Constant() { Value = -1 };
     private Variable variable = new Variable();
     private BinaryFactorVariable binaryFactorVar = new BinaryFactorVariable();
@@ -162,5 +163,5 @@
       int pos = 0;
       while (true) {
-        while (pos < str.Length && Char.IsWhiteSpace(str[pos])) pos++;
+        while (pos < str.Length && char.IsWhiteSpace(str[pos])) pos++;
         if (pos >= str.Length) {
           yield return new Token { TokenType = TokenType.End, strVal = "" };
@@ -168,5 +169,5 @@
         }
         if (char.IsDigit(str[pos])) {
-          // read number (=> read until white space or operator or comma)
+          // read number (=> read until white space or other symbol)
           var sb = new StringBuilder();
           sb.Append(str[pos]);
@@ -269,8 +270,8 @@
         } else if (str[pos] == '<') {
           pos++;
-          yield return new Token {TokenType = TokenType.LeftAngleBracket, strVal = "<"};
+          yield return new Token { TokenType = TokenType.LeftAngleBracket, strVal = "<" };
         } else if (str[pos] == '>') {
           pos++;
-          yield return new Token {TokenType = TokenType.RightAngleBracket, strVal = ">"};
+          yield return new Token { TokenType = TokenType.RightAngleBracket, strVal = ">" };
         } else {
           throw new ArgumentException("Invalid character: " + str[pos]);
@@ -289,32 +290,31 @@
     }
 
-    /// Expr          = ['-' | '+'] Term { '+' Term | '-' Term }
+    /// Expr          = Term { '+' Term | '-' Term }
     private ISymbolicExpressionTreeNode ParseExpr(Queue<Token> tokens) {
+      // build tree from bottom to top and left to right
+      // a + b - c => ((a + b) - c)
+      // a - b - c => ((a - b) - c)
+      // and then flatten as far as possible
+      var left = ParseTerm(tokens);
+
       var next = tokens.Peek();
-      var posTerms = new List<ISymbolicExpressionTreeNode>();
-      var negTerms = new List<ISymbolicExpressionTreeNode>();
-      bool negateFirstTerm = false;
-      if (next.TokenType == TokenType.Operator && (next.strVal == "+" || next.strVal == "-")) {
-        tokens.Dequeue();
-        if (next.strVal == "-")
-          negateFirstTerm = true;
-      }
-      var t = ParseTerm(tokens);
-      if (negateFirstTerm) negTerms.Add(t);
-      else posTerms.Add(t);
-
-      next = tokens.Peek();
       while (next.strVal == "+" || next.strVal == "-") {
         switch (next.strVal) {
           case "+": {
               tokens.Dequeue();
-              var term = ParseTerm(tokens);
-              posTerms.Add(term);
+              var right = ParseTerm(tokens);
+              var op = GetSymbol("+").CreateTreeNode();
+              op.AddSubtree(left);
+              op.AddSubtree(right);
+              left = op;
               break;
             }
           case "-": {
               tokens.Dequeue();
-              var term = ParseTerm(tokens);
-              negTerms.Add(term);
+              var right = ParseTerm(tokens);
+              var op = GetSymbol("-").CreateTreeNode();
+              op.AddSubtree(left);
+              op.AddSubtree(right);
+              left = op;
               break;
             }
@@ -323,26 +323,6 @@
       }
 
-      var sum = GetSymbol("+").CreateTreeNode();
-      foreach (var posTerm in posTerms) sum.AddSubtree(posTerm);
-      if (negTerms.Any()) {
-        if (negTerms.Count == 1) {
-          var sub = GetSymbol("-").CreateTreeNode();
-          sub.AddSubtree(negTerms.Single());
-          sum.AddSubtree(sub);
-        } else {
-          var sumNeg = GetSymbol("+").CreateTreeNode();
-          foreach (var negTerm in negTerms) sumNeg.AddSubtree(negTerm);
-
-          var constNode = (NumberTreeNode)number.CreateTreeNode();
-          constNode.Value = -1.0;
-          var prod = GetSymbol("*").CreateTreeNode();
-          prod.AddSubtree(constNode);
-          prod.AddSubtree(sumNeg);
-
-          sum.AddSubtree(prod);
-        }
-      }
-      if (sum.SubtreeCount == 1) return sum.Subtrees.First();
-      else return sum;
+      FoldLeftRecursive(left);
+      return left;
     }
 
@@ -355,7 +335,10 @@
     /// Term          = Fact { '*' Fact | '/' Fact }
     private ISymbolicExpressionTreeNode ParseTerm(Queue<Token> tokens) {
-      var factors = new List<ISymbolicExpressionTreeNode>();
-      var firstFactor = ParseFact(tokens);
-      factors.Add(firstFactor);
+      // build tree from bottom to top and left to right
+      // a / b * c => ((a / b) * c)
+      // a / b / c => ((a / b) / c)
+      // and then flatten as far as possible
+
+      var left = ParseFact(tokens);
 
       var next = tokens.Peek();
@@ -364,14 +347,19 @@
           case "*": {
               tokens.Dequeue();
-              var fact = ParseFact(tokens);
-              factors.Add(fact);
+              var right = ParseFact(tokens);
+
+              var op = GetSymbol("*").CreateTreeNode();
+              op.AddSubtree(left);
+              op.AddSubtree(right);
+              left = op;
               break;
             }
           case "/": {
               tokens.Dequeue();
-              var invFact = ParseFact(tokens);
-              var divNode = GetSymbol("/").CreateTreeNode(); // 1/x
-              divNode.AddSubtree(invFact);
-              factors.Add(divNode);
+              var right = ParseFact(tokens);
+              var op = GetSymbol("/").CreateTreeNode();
+              op.AddSubtree(left);
+              op.AddSubtree(right);
+              left = op;
               break;
             }
@@ -380,9 +368,22 @@
         next = tokens.Peek();
       }
-      if (factors.Count == 1) return factors.First();
-      else {
-        var prod = GetSymbol("*").CreateTreeNode();
-        foreach (var f in factors) prod.AddSubtree(f);
-        return prod;
+      // remove all nodes where the child op is the same as the parent op
+      // (a * b) * c) => (a * b * c)
+      // (a / b) / c) => (a / b / c)
+
+      FoldLeftRecursive(left);
+      return left;
+    }
+
+    private void FoldLeftRecursive(ISymbolicExpressionTreeNode parent) {
+      if (parent.SubtreeCount > 1) {
+        var child = parent.GetSubtree(0);
+        FoldLeftRecursive(child);
+        if (parent.Symbol == child.Symbol && IsAssociative(parent.Symbol)) {
+          parent.RemoveSubtree(0);
+          for (int i = 0; i < child.SubtreeCount; i++) {
+            parent.InsertSubtree(i, child.GetSubtree(i));
+          }
+        }
       }
     }
@@ -409,5 +410,7 @@
     ///                 | funcId '(' ArgList ')
     ///                 | VarExpr
+    ///                 | '<' 'num' [ '=' [ '+' | '-' ] number ] '>' 
     ///                 | number
+    ///                 | ['+' | '-' ] SimpleFact
     /// ArgList       = Expr { ',' Expr }
     /// VarExpr       = varId OptFactorPart
@@ -433,137 +436,187 @@
         if (tokens.Peek().TokenType == TokenType.LeftPar) {
           // function identifier or LAG
-          var funcId = idTok.strVal.ToUpperInvariant();
-
-          var funcNode = GetSymbol(funcId).CreateTreeNode();
-          var lPar = tokens.Dequeue();
-          if (lPar.TokenType != TokenType.LeftPar)
-            throw new ArgumentException("expected (");
-
-          // handle 'lag' specifically
-          if (funcNode.Symbol is LaggedVariable) {
-            var varId = tokens.Dequeue();
-            if (varId.TokenType != TokenType.Identifier) throw new ArgumentException("Identifier expected. Format for lagged variables: \"lag(x, -1)\"");
-            var comma = tokens.Dequeue();
-            if (comma.TokenType != TokenType.Comma) throw new ArgumentException("',' expected, Format for lagged variables: \"lag(x, -1)\"");
-            double sign = 1.0;
-            if (tokens.Peek().strVal == "+" || tokens.Peek().strVal == "-") {
-              // read sign
-              var signTok = tokens.Dequeue();
-              if (signTok.strVal == "-") sign = -1.0;
-            }
-            var lagToken = tokens.Dequeue();
-            if (lagToken.TokenType != TokenType.Number) throw new ArgumentException("Number expected, Format for lagged variables: \"lag(x, -1)\"");
-            if (!lagToken.doubleVal.IsAlmost(Math.Round(lagToken.doubleVal)))
-              throw new ArgumentException("Time lags must be integer values");
-            var laggedVarNode = funcNode as LaggedVariableTreeNode;
-            laggedVarNode.VariableName = varId.strVal;
-            laggedVarNode.Lag = (int)Math.Round(sign * lagToken.doubleVal);
-            laggedVarNode.Weight = 1.0;
+          return ParseFunctionOrLaggedVariable(tokens, idTok);
+        } else {
+          return ParseVariable(tokens, idTok);
+        }
+      } else if (next.TokenType == TokenType.LeftAngleBracket) {
+        // '<' 'num' [ '=' ['+'|'-'] number ] '>'
+        return ParseNumber(tokens);
+      } else if (next.TokenType == TokenType.Operator && (next.strVal == "-" || next.strVal == "+")) {
+        // ['+' | '-' ] SimpleFact
+        if (tokens.Dequeue().strVal == "-") {
+          var arg = ParseSimpleFact(tokens);
+          if (arg is NumberTreeNode numNode) {
+            numNode.Value *= -1;
+            return numNode;
+          } else if (arg is ConstantTreeNode constNode) {
+            var constSy = new Constant { Value = -constNode.Value };
+            return constSy.CreateTreeNode();
+          } else if (arg is VariableTreeNode varNode) {
+            varNode.Weight *= -1;
+            return varNode;
           } else {
-            // functions
-            var args = ParseArgList(tokens);
-            // check number of arguments
-            if (funcNode.Symbol.MinimumArity > args.Length || funcNode.Symbol.MaximumArity < args.Length) {
-              throw new ArgumentException(string.Format("Symbol {0} requires between {1} and  {2} arguments.", funcId,
-                funcNode.Symbol.MinimumArity, funcNode.Symbol.MaximumArity));
-            }
-            foreach (var arg in args) funcNode.AddSubtree(arg);
+            var mul = GetSymbol("*").CreateTreeNode();
+            var neg = minusOne.CreateTreeNode();
+            mul.AddSubtree(neg);
+            mul.AddSubtree(arg);
+            return mul;
           }
-
-          var rPar = tokens.Dequeue();
-          if (rPar.TokenType != TokenType.RightPar)
-            throw new ArgumentException("expected )");
-
-
-          return funcNode;
         } else {
-          // variable
-          if (tokens.Peek().TokenType == TokenType.Eq) {
-            // binary factor
-            tokens.Dequeue(); // skip Eq
-            var valTok = tokens.Dequeue();
-            if (valTok.TokenType != TokenType.Identifier) throw new ArgumentException("expected identifier");
-            var binFactorNode = (BinaryFactorVariableTreeNode)binaryFactorVar.CreateTreeNode();
-            binFactorNode.Weight = 1.0;
-            binFactorNode.VariableName = idTok.strVal;
-            binFactorNode.VariableValue = valTok.strVal;
-            return binFactorNode;
-          } else if (tokens.Peek().TokenType == TokenType.LeftBracket) {
-            // factor variable
-            var factorVariableNode = (FactorVariableTreeNode)factorVar.CreateTreeNode();
-            factorVariableNode.VariableName = idTok.strVal;
-
-            tokens.Dequeue(); // skip [
-            var weights = new List<double>();
-            // at least one weight is necessary
-            var sign = 1.0;
-            if (tokens.Peek().TokenType == TokenType.Operator) {
-              var opToken = tokens.Dequeue();
-              if (opToken.strVal == "+") sign = 1.0;
-              else if (opToken.strVal == "-") sign = -1.0;
-              else throw new ArgumentException();
-            }
-            if (tokens.Peek().TokenType != TokenType.Number) throw new ArgumentException("number expected");
-            var weightTok = tokens.Dequeue();
-            weights.Add(sign * weightTok.doubleVal);
-            while (tokens.Peek().TokenType == TokenType.Comma) {
-              // skip comma
-              tokens.Dequeue();
-              if (tokens.Peek().TokenType == TokenType.Operator) {
-                var opToken = tokens.Dequeue();
-                if (opToken.strVal == "+") sign = 1.0;
-                else if (opToken.strVal == "-") sign = -1.0;
-                else throw new ArgumentException();
-              }
-              weightTok = tokens.Dequeue();
-              if (weightTok.TokenType != TokenType.Number) throw new ArgumentException("number expected");
-              weights.Add(sign * weightTok.doubleVal);
-            }
-            var rightBracketToken = tokens.Dequeue();
-            if (rightBracketToken.TokenType != TokenType.RightBracket) throw new ArgumentException("closing bracket ] expected");
-            factorVariableNode.Weights = weights.ToArray();
-            return factorVariableNode;
-          } else {
-            // variable
-            var varNode = (VariableTreeNode)variable.CreateTreeNode();
-            varNode.Weight = 1.0;
-            varNode.VariableName = idTok.strVal;
-            return varNode;
-          }
-        }
-      } else if (next.TokenType == TokenType.LeftAngleBracket) {
-        Token numberTok = null;
-        var leftAngleBracket = tokens.Dequeue();
-        if (leftAngleBracket.TokenType != TokenType.LeftAngleBracket)
-          throw new ArgumentException("opening bracket < expected");
-
-        var idTok = tokens.Dequeue();
-        if (idTok.TokenType != TokenType.Identifier || idTok.strVal.ToLower() != "num")
-          throw new ArgumentException("string 'num' expected");
-
-        if (tokens.Peek().TokenType == TokenType.Eq) {
-          var equalTok = tokens.Dequeue();
-          if (tokens.Peek().TokenType != TokenType.Number)
-            throw new ArgumentException("No value for number specified.");
-
-          numberTok = tokens.Dequeue();
-        }
-
-        var rightAngleBracket = tokens.Dequeue();
-        if (rightAngleBracket.TokenType != TokenType.RightAngleBracket)
-          throw new ArgumentException("closing bracket > expected");
-        var numNode = (NumberTreeNode)number.CreateTreeNode();
-        if (numberTok != null) numNode.Value = numberTok.doubleVal;
-        return numNode;
+          return ParseSimpleFact(tokens);
+        }
       } else if (next.TokenType == TokenType.Number) {
+        // number
         var numTok = tokens.Dequeue();
-        var constSy = new Constant {Value = numTok.doubleVal};
+        var constSy = new Constant { Value = numTok.doubleVal };
         return constSy.CreateTreeNode();
-        /*var constNode = (ConstantTreeNode)constant.CreateTreeNode();
-        constNode.Value = numTok.doubleVal;
-        return constNode;*/
       } else {
         throw new ArgumentException(string.Format("unexpected token in expression {0}", next.strVal));
       }
+    }
+
+    private ISymbolicExpressionTreeNode ParseNumber(Queue<Token> tokens) {
+      // we distinguish parameters and constants. The values of parameters can be changed.
+      // a parameter is written as '<' 'num' [ '=' ['+'|'-'] number ] '>' with an optional initialization 
+      Token numberTok = null;
+      var leftAngleBracket = tokens.Dequeue();
+      if (leftAngleBracket.TokenType != TokenType.LeftAngleBracket)
+        throw new ArgumentException("opening bracket < expected");
+
+      var idTok = tokens.Dequeue();
+      if (idTok.TokenType != TokenType.Identifier || idTok.strVal.ToLower() != "num")
+        throw new ArgumentException("string 'num' expected");
+
+      var numNode = (NumberTreeNode)number.CreateTreeNode();
+
+      if (tokens.Peek().TokenType == TokenType.Eq) {
+        tokens.Dequeue(); // skip "="
+        var next = tokens.Peek();
+        if (next.strVal != "+" && next.strVal != "-" && next.TokenType != TokenType.Number)
+          throw new ArgumentException("Expected '+', '-' or number.");
+
+        var sign = 1.0;
+        if (next.strVal == "+" || next.strVal == "-") {
+          if (tokens.Dequeue().strVal == "-") sign = -1.0;
+        }
+        if (tokens.Peek().TokenType != TokenType.Number) {
+          throw new ArgumentException("Expected number.");
+        }
+        numberTok = tokens.Dequeue();
+        numNode.Value = sign * numberTok.doubleVal;
+      }
+
+      var rightAngleBracket = tokens.Dequeue();
+      if (rightAngleBracket.TokenType != TokenType.RightAngleBracket)
+        throw new ArgumentException("closing bracket > expected");
+
+      return numNode;
+    }
+
+    private ISymbolicExpressionTreeNode ParseVariable(Queue<Token> tokens, Token idTok) {
+      // variable
+      if (tokens.Peek().TokenType == TokenType.Eq) {
+        // binary factor
+        tokens.Dequeue(); // skip Eq
+        var valTok = tokens.Dequeue();
+        if (valTok.TokenType != TokenType.Identifier) throw new ArgumentException("expected identifier");
+        var binFactorNode = (BinaryFactorVariableTreeNode)binaryFactorVar.CreateTreeNode();
+        binFactorNode.Weight = 1.0;
+        binFactorNode.VariableName = idTok.strVal;
+        binFactorNode.VariableValue = valTok.strVal;
+        return binFactorNode;
+      } else if (tokens.Peek().TokenType == TokenType.LeftBracket) {
+        // factor variable
+        var factorVariableNode = (FactorVariableTreeNode)factorVar.CreateTreeNode();
+        factorVariableNode.VariableName = idTok.strVal;
+
+        tokens.Dequeue(); // skip [
+        var weights = new List<double>();
+        // at least one weight is necessary
+        var sign = 1.0;
+        if (tokens.Peek().TokenType == TokenType.Operator) {
+          var opToken = tokens.Dequeue();
+          if (opToken.strVal == "+") sign = 1.0;
+          else if (opToken.strVal == "-") sign = -1.0;
+          else throw new ArgumentException();
+        }
+        if (tokens.Peek().TokenType != TokenType.Number) throw new ArgumentException("number expected");
+        var weightTok = tokens.Dequeue();
+        weights.Add(sign * weightTok.doubleVal);
+        while (tokens.Peek().TokenType == TokenType.Comma) {
+          // skip comma
+          tokens.Dequeue();
+          if (tokens.Peek().TokenType == TokenType.Operator) {
+            var opToken = tokens.Dequeue();
+            if (opToken.strVal == "+") sign = 1.0;
+            else if (opToken.strVal == "-") sign = -1.0;
+            else throw new ArgumentException();
+          }
+          weightTok = tokens.Dequeue();
+          if (weightTok.TokenType != TokenType.Number) throw new ArgumentException("number expected");
+          weights.Add(sign * weightTok.doubleVal);
+        }
+        var rightBracketToken = tokens.Dequeue();
+        if (rightBracketToken.TokenType != TokenType.RightBracket) throw new ArgumentException("closing bracket ] expected");
+        factorVariableNode.Weights = weights.ToArray();
+        return factorVariableNode;
+      } else {
+        // variable
+        var varNode = (VariableTreeNode)variable.CreateTreeNode();
+        varNode.Weight = 1.0;
+        varNode.VariableName = idTok.strVal;
+        return varNode;
+      }
+    }
+
+    private ISymbolicExpressionTreeNode ParseFunctionOrLaggedVariable(Queue<Token> tokens, Token idTok) {
+      var funcId = idTok.strVal.ToUpperInvariant();
+
+      var funcNode = GetSymbol(funcId).CreateTreeNode();
+      var lPar = tokens.Dequeue();
+      if (lPar.TokenType != TokenType.LeftPar)
+        throw new ArgumentException("expected (");
+
+      // handle 'lag' specifically
+      if (funcNode.Symbol is LaggedVariable) {
+        ParseLaggedVariable(tokens, funcNode);
+      } else {
+        // functions
+        var args = ParseArgList(tokens);
+        // check number of arguments
+        if (funcNode.Symbol.MinimumArity > args.Length || funcNode.Symbol.MaximumArity < args.Length) {
+          throw new ArgumentException(string.Format("Symbol {0} requires between {1} and  {2} arguments.", funcId,
+            funcNode.Symbol.MinimumArity, funcNode.Symbol.MaximumArity));
+        }
+        foreach (var arg in args) funcNode.AddSubtree(arg);
+      }
+
+      var rPar = tokens.Dequeue();
+      if (rPar.TokenType != TokenType.RightPar)
+        throw new ArgumentException("expected )");
+
+
+      return funcNode;
+    }
+
+    private static void ParseLaggedVariable(Queue<Token> tokens, ISymbolicExpressionTreeNode funcNode) {
+      var varId = tokens.Dequeue();
+      if (varId.TokenType != TokenType.Identifier) throw new ArgumentException("Identifier expected. Format for lagged variables: \"lag(x, -1)\"");
+      var comma = tokens.Dequeue();
+      if (comma.TokenType != TokenType.Comma) throw new ArgumentException("',' expected, Format for lagged variables: \"lag(x, -1)\"");
+      double sign = 1.0;
+      if (tokens.Peek().strVal == "+" || tokens.Peek().strVal == "-") {
+        // read sign
+        var signTok = tokens.Dequeue();
+        if (signTok.strVal == "-") sign = -1.0;
+      }
+      var lagToken = tokens.Dequeue();
+      if (lagToken.TokenType != TokenType.Number) throw new ArgumentException("Number expected, Format for lagged variables: \"lag(x, -1)\"");
+      if (!lagToken.doubleVal.IsAlmost(Math.Round(lagToken.doubleVal)))
+        throw new ArgumentException("Time lags must be integer values");
+      var laggedVarNode = funcNode as LaggedVariableTreeNode;
+      laggedVarNode.VariableName = varId.strVal;
+      laggedVarNode.Lag = (int)Math.Round(sign * lagToken.doubleVal);
+      laggedVarNode.Weight = 1.0;
     }
 
@@ -579,4 +632,10 @@
       return exprList.ToArray();
     }
+
+    private bool IsAssociative(ISymbol sy) {
+      return sy == GetSymbol("+") || sy == GetSymbol("-") ||
+             sy == GetSymbol("*") || sy == GetSymbol("/") ||
+             sy == GetSymbol("AND") || sy == GetSymbol("OR") || sy == GetSymbol("XOR");
+    }
   }
 }
Index: /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs	(revision 18175)
@@ -70,9 +70,9 @@
       if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) {
         timeFrameLabel.Select();  // select label to validate data
-      }
-
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else  if (e.KeyCode == Keys.Escape) {
         timeframeTextbox.Text = lastFramesValue;
         timeFrameLabel.Select();  // select label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisResultsView.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisResultsView.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisResultsView.cs	(revision 18175)
@@ -107,10 +107,11 @@
 
     private void TrainingHorizonTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         TrainingHorizonLabel.Select();  // select label to validate data
-
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         TrainingHorizonTextBox.Text = Content.TrainingHorizon.ToString();
         TrainingHorizonLabel.Select();  // select label to validate data
+        e.SuppressKeyPress = true;
       }
     }
@@ -132,10 +133,11 @@
 
     private void TestHorizonTextBox_KeyDown(object sender, KeyEventArgs e) {
-      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
         TestHorizonLabel.Select();  // select label to validate data
-
-      if (e.KeyCode == Keys.Escape) {
+        e.SuppressKeyPress = true;
+      } else if (e.KeyCode == Keys.Escape) {
         TestHorizonTextBox.Text = Content.TestHorizon.ToString();
         TestHorizonLabel.Select();  // select label to validate data
+        e.SuppressKeyPress = true;
       }
     }
Index: /branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs	(revision 18175)
@@ -34,41 +34,40 @@
     public void DeriveExpressions() {
       var formatter = new InfixExpressionFormatter();
-      var parser = new InfixExpressionParser();
       Assert.AreEqual("0", Derive("<num=3>", "x"));
       Assert.AreEqual("1", Derive("x", "x"));
       Assert.AreEqual("10", Derive("<num=10>*x", "x"));
       Assert.AreEqual("10", Derive("x*<num=10>", "x"));
-      Assert.AreEqual("(2*'x')", Derive("x*x", "x"));
-      Assert.AreEqual("((('x' * 'x') * 2) + ('x' * 'x'))", Derive("x*x*x", "x")); // simplifier does not merge (x*x)*2 + x*x  to 3*x*x
+      Assert.AreEqual("2*'x'", Derive("x*x", "x"));
+      Assert.AreEqual("'x' * 'x' * 2 + 'x' * 'x'", Derive("x*x*x", "x")); // simplifier does not merge (x*x)*2 + x*x  to 3*x*x
       Assert.AreEqual("0", Derive("<num=10>*x", "y"));
       Assert.AreEqual("20", Derive("<num=10>*x+<num=20>*y", "y"));
       Assert.AreEqual("6", Derive("<num=2>*<num=3>*x", "x"));
-      Assert.AreEqual("(10*'y')", Derive("<num=10>*x*y+<num=20>*y", "x"));
-      Assert.AreEqual("(1 / (SQR('x') * (-1)))", Derive("1/x", "x"));
-      Assert.AreEqual("('y' / (SQR('x') * (-1)))", Derive("y/x", "x"));
-      Assert.AreEqual("((((-2*'x') + (-1)) * ('a' + 'b')) / SQR(('x' + ('x' * 'x'))))",
+      Assert.AreEqual("10*'y'", Derive("<num=10>*x*y+<num=20>*y", "x"));
+      Assert.AreEqual("1 * -1 / SQR('x')", Derive("1/x", "x"));
+      Assert.AreEqual("-1*'y' / SQR('x')", Derive("y/x", "x"));
+      Assert.AreEqual("('a' + 'b') * (-2*'x' + -1) / SQR('x' + 'x' * 'x')",
         Derive("(a+b)/(x+x*x)", "x"));
-      Assert.AreEqual("((((-2*'x') + (-1)) * ('a' + 'b')) / SQR(('x' + SQR('x'))))", Derive("(a+b)/(x+SQR(x))", "x"));
+      Assert.AreEqual("('a' + 'b') * (-2*'x' + -1) / SQR('x' + SQR('x'))", Derive("(a+b)/(x+SQR(x))", "x"));
       Assert.AreEqual("EXP('x')", Derive("exp(x)", "x"));
-      Assert.AreEqual("(EXP((3*'x')) * 3)", Derive("exp(<num=3>*x)", "x"));
-      Assert.AreEqual("(1 / 'x')", Derive("log(x)", "x"));
-      Assert.AreEqual("(1 / 'x')", Derive("log(<num=3>*x)", "x"));   // 3 * 1/(3*x)
-      Assert.AreEqual("(1 / ('x' + (0.333333333333333*'y')))", Derive("log(<num=3>*x+y)", "x"));  // simplifier does not try to keep fractions
-      Assert.AreEqual("(1 / (SQRT(((3*'x') + 'y')) * 0.666666666666667))", Derive("sqrt(<num=3>*x+y)", "x"));   // 3 / (2 * sqrt(3*x+y)) = 1 / ((2/3) * sqrt(3*x+y)) 
-      Assert.AreEqual("(COS((3*'x')) * 3)", Derive("sin(<num=3>*x)", "x"));
-      Assert.AreEqual("(SIN((3*'x')) * (-3))", Derive("cos(<num=3>*x)", "x"));
-      Assert.AreEqual("(1 / (SQR(COS((3*'x'))) * 0.333333333333333))", Derive("tan(<num=3>*x)", "x")); // diff(tan(f(x)), x) = 1.0 / cos²(f(x)), simplifier puts constant factor into the denominator
+      Assert.AreEqual("EXP(3*'x') * 3", Derive("exp(<num=3>*x)", "x"));
+      Assert.AreEqual("1 / 'x'", Derive("log(x)", "x"));
+      Assert.AreEqual("1 / 'x'", Derive("log(<num=3>*x)", "x"));   // 3 * 1/(3*x)
+      Assert.AreEqual("1 / ('x' + 0.333333333333333*'y')", Derive("log(<num=3>*x+y)", "x"));  // simplifier does not try to keep fractions
+      Assert.AreEqual("1 / (SQRT(3*'x' + 'y') * 0.666666666666667)", Derive("sqrt(<num=3>*x+y)", "x"));   // 3 / (2 * sqrt(3*x+y)) = 1 / ((2/3) * sqrt(3*x+y)) 
+      Assert.AreEqual("COS(3*'x') * 3", Derive("sin(<num=3>*x)", "x"));
+      Assert.AreEqual("SIN(3*'x') * -3", Derive("cos(<num=3>*x)", "x"));
+      Assert.AreEqual("1 / (SQR(COS(3*'x')) * 0.333333333333333)", Derive("tan(<num=3>*x)", "x")); // diff(tan(f(x)), x) = 1.0 / cos²(f(x)), simplifier puts constant factor into the denominator
 
-      Assert.AreEqual("((9*'x') / ABS((3*'x')))", Derive("abs(<num=3>*x)", "x"));
-      Assert.AreEqual("(SQR('x') * 3)", Derive("cube(x)", "x"));
-      Assert.AreEqual("(1 / (SQR(CUBEROOT('x')) * 3))", Derive("cuberoot(x)", "x"));
+      Assert.AreEqual("9*'x' / ABS(3*'x')", Derive("abs(<num=3>*x)", "x"));
+      Assert.AreEqual("SQR('x') * 3", Derive("cube(x)", "x"));
+      Assert.AreEqual("1 / (SQR(CUBEROOT('x')) * 3)", Derive("cuberoot(x)", "x"));
 
       Assert.AreEqual("0", Derive("(a+b)/(x+SQR(x))", "y")); // df(a,b,x) / dy = 0
 
 
-      Assert.AreEqual("('a' * 'b' * 'c')", Derive("a*b*c*d", "d"));
-      Assert.AreEqual("('a' / ('b' * 'c' * SQR('d') * (-1)))", Derive("a/b/c/d", "d"));
+      Assert.AreEqual("'a' * 'b' * 'c'", Derive("a*b*c*d", "d"));
+      Assert.AreEqual("'b' * 'c' * -1*'a' / (SQR('b') * SQR('c') * SQR('d'))", Derive("a/b/c/d", "d")); // TODO simplifier should be able to simplify this
 
-      Assert.AreEqual("('x' * ((SQR(TANH(SQR('x'))) * (-1)) + 1) * 2)", Derive("tanh(sqr(x))", "x")); // (2*'x'*(1 - SQR(TANH(SQR('x'))))
+      Assert.AreEqual("'x' * (SQR(TANH(SQR('x'))) * -1 + 1) * 2", Derive("tanh(sqr(x))", "x")); // (2*'x'*(1 - SQR(TANH(SQR('x'))))
 
       {
@@ -85,5 +84,5 @@
         root.AddSubtree(start);
         var t = new SymbolicExpressionTree(root);
-        Assert.AreEqual("(1 / (SQR('x') * (-1)))",
+        Assert.AreEqual("1 / (SQR('x') * -1)",
           formatter.Format(DerivativeCalculator.Derive(t, "x")));
       }
@@ -125,11 +124,11 @@
         var t = new SymbolicExpressionTree(root);
 
-        Assert.AreEqual("(('y' * 'z' * 60) / (SQR('y') * SQR('z') * 400))", // actually 3 / (4y  5z) but simplifier is not smart enough to cancel numerator and denominator
+        Assert.AreEqual("'y' * 'z' * 60 / (SQR('y') * SQR('z') * 400)", // actually 3 / (4y  5z) but simplifier is not smart enough to cancel numerator and denominator
                                                                             // 60 y z / y² z² 20² == 6 / y z 40 == 3 / y z 20
           formatter.Format(DerivativeCalculator.Derive(t, "x")));
-        Assert.AreEqual("(('x' * 'z' * (-60)) / (SQR('y') * SQR('z') * 400))", // actually 3x * -(4 5 z) / (4y 5z)² = -3x / (20 y² z)
+        Assert.AreEqual("'x' * 'z' * -60 / (SQR('y') * SQR('z') * 400)", // actually 3x * -(4 5 z) / (4y 5z)² = -3x / (20 y² z)
                                                                                // -3 4 5 x z / 4² y² 5² z² = -60 x z / 20² z² y² ==    -60 x z / y² z² 20² 
           formatter.Format(DerivativeCalculator.Derive(t, "y")));
-        Assert.AreEqual("(('x' * 'y' * (-60)) / (SQR('y') * SQR('z') * 400))",
+        Assert.AreEqual("'x' * 'y' * -60 / (SQR('y') * SQR('z') * 400)",
           formatter.Format(DerivativeCalculator.Derive(t, "z")));
       }
Index: /branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/InfixExpressionParserTest.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/InfixExpressionParserTest.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/InfixExpressionParserTest.cs	(revision 18175)
@@ -34,91 +34,118 @@
       var formatter = new InfixExpressionFormatter();
       var parser = new InfixExpressionParser();
-      Console.WriteLine(formatter.Format(parser.Parse("3")));
-      Console.WriteLine(formatter.Format(parser.Parse("3*3")));
-      Console.WriteLine(formatter.Format(parser.Parse("3 * 4")));
-      Console.WriteLine(formatter.Format(parser.Parse("123E-03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123e-03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123e+03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123E+03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0E-03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0e-03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0e+03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0E+03")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0E-3")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0e-3")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0e+3")));
-      Console.WriteLine(formatter.Format(parser.Parse("123.0E+3")));
+      Assert.AreEqual("3", formatter.Format(parser.Parse("3")));
+      Assert.AreEqual("3 * 3", formatter.Format(parser.Parse("3*3")));
+      Assert.AreEqual("3 * 4",formatter.Format(parser.Parse("3 * 4")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123E-03")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123e-03")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123e+03")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123E+03")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123.0E-03")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123.0e-03")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123.0e+03")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123.0E+03")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123.0E-3")));
+      Assert.AreEqual("0.123",formatter.Format(parser.Parse("123.0e-3")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123.0e+3")));
+      Assert.AreEqual("123000",formatter.Format(parser.Parse("123.0E+3")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415+2.0")));
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415/2.0")));
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415*2.0")));
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415-2.0")));
+      Assert.AreEqual("3.1415 + 2",formatter.Format(parser.Parse("3.1415+2.0")));
+      Assert.AreEqual("3.1415 / 2",formatter.Format(parser.Parse("3.1415/2.0")));
+      Assert.AreEqual("3.1415 * 2",formatter.Format(parser.Parse("3.1415*2.0")));
+      Assert.AreEqual("3.1415 - 2", formatter.Format(parser.Parse("3.1415-2.0")));
       // round-trip
-      Console.WriteLine(formatter.Format(parser.Parse(formatter.Format(parser.Parse("3.1415-2.0")))));
-      Console.WriteLine(formatter.Format(parser.Parse("3.1415+(2.0)")));
-      Console.WriteLine(formatter.Format(parser.Parse("(3.1415+(2.0))")));
+      Assert.AreEqual("3.1415 - 2",formatter.Format(parser.Parse(formatter.Format(parser.Parse("3.1415-2.0")))));
+      Assert.AreEqual("3.1415 + 2",formatter.Format(parser.Parse("3.1415+(2.0)")));
+      Assert.AreEqual("3.1415 + 2", formatter.Format(parser.Parse("(3.1415+(2.0))")));
 
 
-      Console.WriteLine(formatter.Format(parser.Parse("log(3)")));
-      Console.WriteLine(formatter.Format(parser.Parse("log(-3)")));   // should produce log(-3) as output
-      Console.WriteLine(formatter.Format(parser.Parse("exp(3)")));
-      Console.WriteLine(formatter.Format(parser.Parse("exp(-3)")));  // should produce exp(-3) as output
-      Console.WriteLine(formatter.Format(parser.Parse("sqrt(3)")));
+      Assert.AreEqual("LOG(3)",formatter.Format(parser.Parse("log(3)")));
+      Assert.AreEqual("LOG(-3)",formatter.Format(parser.Parse("log(-3)")));
+      Assert.AreEqual("EXP(3)",formatter.Format(parser.Parse("exp(3)")));
+      Assert.AreEqual("EXP(-3)",formatter.Format(parser.Parse("exp(-3)")));
+      Assert.AreEqual("SQRT(3)", formatter.Format(parser.Parse("sqrt(3)")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("sqr((-3))")));  // should produce sqr((-3)) as output
+      Assert.AreEqual("SQR(-3)", formatter.Format(parser.Parse("sqr((-3))")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("3/3+2/2+1/1"))); // ((3 * 1 / 3) + (2 * 1 / 2) + (1 * 1 / 1))
-      Console.WriteLine(formatter.Format(parser.Parse("-3+30-2+20-1+10")));   //  not (30 + 20 + 10 + ((-1) * (3 + 2 + 1)))
-      // round trip
-      Console.WriteLine(formatter.Format(parser.Parse(formatter.Format(parser.Parse("-3+30-2+20-1+10")))));   // not (30 + 20 + 10 + ((-(1)) * (3 + 2 + 1)))
+      Assert.AreEqual("3 / 3 + 2 / 2 + 1 / 1",formatter.Format(parser.Parse("3/3+2/2+1/1")));
+      Assert.AreEqual("-3 + 30 - 2 + 20 - 1 + 10", formatter.Format(parser.Parse("-3+30-2+20-1+10")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("\"x1\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("\'var name\'")));
-      Console.WriteLine(formatter.Format(parser.Parse("\"var name\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("\"1\"")));
+      // 'flattening' of nested addition, subtraction, multiplication, or division
+      Assert.AreEqual("1 + 2 + 3 + 4", formatter.Format(parser.Parse("1 + 2 + 3 + 4")));
+      Assert.AreEqual("1 - 2 - 3 - 4", formatter.Format(parser.Parse("1 - 2 - 3 - 4")));
+      Assert.AreEqual("1 * 2 * 3 * 4", formatter.Format(parser.Parse("1 * 2 * 3 * 4")));
+      Assert.AreEqual("1 / 2 / 3 / 4", formatter.Format(parser.Parse("1 / 2 / 3 / 4")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("'var \" name\'")));
-      Console.WriteLine(formatter.Format(parser.Parse("\"var \' name\"")));
+      // signed variables / constants
+      Assert.AreEqual("-1*'x1'", formatter.Format(parser.Parse("-x1")));
+      Assert.AreEqual("1", formatter.Format(parser.Parse("--1.0")));
+      Assert.AreEqual("1", formatter.Format(parser.Parse("----1.0")));
+      Assert.AreEqual("1", formatter.Format(parser.Parse("-+-1.0")));
+      Assert.AreEqual("1", formatter.Format(parser.Parse("+-+-1.0")));
+      Assert.AreEqual("-3 + -1", formatter.Format(parser.Parse("-3 + -1.0")));
 
 
-      Console.WriteLine(formatter.Format(parser.Parse("\"x1\"*\"x2\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("\"x1\"*\"x2\"+\"x3\"*\"x4\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("x1*x2+x3*x4")));
+      Assert.AreEqual("'x1'",formatter.Format(parser.Parse("\"x1\"")));
+      Assert.AreEqual("'var name'",formatter.Format(parser.Parse("\'var name\'")));
+      Assert.AreEqual("'var name'",formatter.Format(parser.Parse("\"var name\"")));
+      Assert.AreEqual("'1'",formatter.Format(parser.Parse("\"1\"")));
+
+      Assert.AreEqual("'var \" name'",formatter.Format(parser.Parse("'var \" name\'")));
+      Assert.AreEqual("\"var ' name\"", formatter.Format(parser.Parse("\"var \' name\"")));
 
 
-      Console.WriteLine(formatter.Format(parser.Parse("POW(3, 2)")));
-      Console.WriteLine(formatter.Format(parser.Parse("POW(3.1, 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("POW(3.1 , 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("POW(3.1 ,2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("POW(-3.1 , - 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(3, 2)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(3.1, 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(3.1 , 2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(3.1 ,2.1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("ROOT(-3.1 , - 2.1)")));
+      Assert.AreEqual("'x1' * 'x2'",formatter.Format(parser.Parse("\"x1\"*\"x2\"")));
+      Assert.AreEqual("'x1' * 'x2' + 'x3' * 'x4'",formatter.Format(parser.Parse("\"x1\"*\"x2\"+\"x3\"*\"x4\"")));
+      Assert.AreEqual("'x1' * 'x2' + 'x3' * 'x4'", formatter.Format(parser.Parse("x1*x2+x3*x4")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("IF(GT( 0, 1), 1, 0)")));
-      Console.WriteLine(formatter.Format(parser.Parse("IF(LT(0,1), 1 , 0)")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("LAG(x, 1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("LAG(x, -1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("LAG(x, +1)")));
-      Console.WriteLine(formatter.Format(parser.Parse("x * LAG('x', +1)")));
+      Assert.AreEqual("3 ^ 2",formatter.Format(parser.Parse("POW(3, 2)")));
+      Assert.AreEqual("3.1 ^ 2.1",formatter.Format(parser.Parse("POW(3.1, 2.1)")));
+      Assert.AreEqual("3.1 ^ 2.1",formatter.Format(parser.Parse("POW(3.1 , 2.1)")));
+      Assert.AreEqual("3.1 ^ 2.1",formatter.Format(parser.Parse("POW(3.1 ,2.1)")));
+      Assert.AreEqual("-3.1 ^ -2.1",formatter.Format(parser.Parse("POW(-3.1 , - 2.1)")));
+      Assert.AreEqual("ROOT(3, 2)",formatter.Format(parser.Parse("ROOT(3, 2)")));
+      Assert.AreEqual("ROOT(3.1, 2.1)",formatter.Format(parser.Parse("ROOT(3.1, 2.1)")));
+      Assert.AreEqual("ROOT(3.1, 2.1)",formatter.Format(parser.Parse("ROOT(3.1 , 2.1)")));
+      Assert.AreEqual("ROOT(3.1, 2.1)",formatter.Format(parser.Parse("ROOT(3.1 ,2.1)")));
+      Assert.AreEqual("ROOT(-3.1, -2.1)", formatter.Format(parser.Parse("ROOT(-3.1 , -2.1)")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("x [1.0] * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x [1.0, 2.0] * y [1.0, 2.0]")));
-      Console.WriteLine(formatter.Format(parser.Parse("x[1] * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x[1, 2] * y [1, 2]")));
+      Assert.AreEqual("IF(GT(0, 1), 1, 0)",formatter.Format(parser.Parse("IF(GT( 0, 1), 1, 0)")));
+      Assert.AreEqual("IF(LT(0, 1), 1, 0)",formatter.Format(parser.Parse("IF(LT(0,1), 1 , 0)")));
+      Assert.AreEqual("LAG('x', 1)",formatter.Format(parser.Parse("LAG(x, 1)")));
+      Assert.AreEqual("LAG('x', -1)",formatter.Format(parser.Parse("LAG(x, -1)")));
+      Assert.AreEqual("LAG('x', 1)",formatter.Format(parser.Parse("LAG(x, +1)")));
+      Assert.AreEqual("'x' * LAG('x', 1)", formatter.Format(parser.Parse("x * LAG('x', +1)")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("x [+1.0] * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x [-1.0] * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x [-1.0, -2.0] * y [+1.0, +2.0]")));
+      // factor variables
+      Assert.AreEqual("'x'[1] * 'y'",formatter.Format(parser.Parse("x [1.0] * y")));
+      Assert.AreEqual("'x'[1, 2] * 'y'[1, 2]",formatter.Format(parser.Parse("x [1.0, 2.0] * y [1.0, 2.0]")));
+      Assert.AreEqual("'x'[1] * 'y'",formatter.Format(parser.Parse("x[1] * y")));
+      Assert.AreEqual("'x'[1, 2] * 'y'[1, 2]",formatter.Format(parser.Parse("x[1, 2] * y [1, 2]")));
+      Assert.AreEqual("'x'[1] * 'y'",formatter.Format(parser.Parse("x [+1.0] * y")));
+      Assert.AreEqual("'x'[-1] * 'y'",formatter.Format(parser.Parse("x [-1.0] * y")));
+      Assert.AreEqual("'x'[-1, -2] * 'y'[1, 2]", formatter.Format(parser.Parse("x [-1.0, -2.0] * y [+1.0, +2.0]")));
 
-      Console.WriteLine(formatter.Format(parser.Parse("x='bla' * y")));
-      Console.WriteLine(formatter.Format(parser.Parse("x = 'bla'")));
-      Console.WriteLine(formatter.Format(parser.Parse("x = \"bla\"")));
-      Console.WriteLine(formatter.Format(parser.Parse("1.0 * x = bla")));
-      Console.WriteLine(formatter.Format(parser.Parse("-1.0 * x = bla")));
-      Console.WriteLine(formatter.Format(parser.Parse("+1.0 * \"x\" = bla + y = \"bla2\"")));
+      // one-hot for factor
+      Assert.AreEqual("'x' = 'val' * 'y'",formatter.Format(parser.Parse("x='val' * y")));
+      Assert.AreEqual("'x' = 'val'",formatter.Format(parser.Parse("x = 'val'")));
+      Assert.AreEqual("'x' = 'val'",formatter.Format(parser.Parse("x = \"val\"")));
+      Assert.AreEqual("1 * 'x' = 'val'",formatter.Format(parser.Parse("1.0 * x = val")));
+      Assert.AreEqual("-1 * 'x' = 'val'",formatter.Format(parser.Parse("-1.0 * x = val")));
+      Assert.AreEqual("1 * 'x' = 'val1' + 'y' = 'val2'", formatter.Format(parser.Parse("+1.0 * \"x\" = val1 + y = \"val2\"")));
+
+      // numeric parameters
+      Assert.AreEqual("0", formatter.Format(parser.Parse("<num>"))); // default initial value is zero
+      Assert.AreEqual("0", formatter.Format(parser.Parse("< num >")));
+      Assert.AreEqual("1", formatter.Format(parser.Parse("< num=1.0>")));
+      Assert.AreEqual("1", formatter.Format(parser.Parse("< num = 1.0>")));
+      Assert.AreEqual("-1", formatter.Format(parser.Parse("< num =-1.0>")));
+      Assert.AreEqual("-1", formatter.Format(parser.Parse("< num = - 1.0>")));
+      
+      // numeric parameter with sign
+      Assert.AreEqual("1", formatter.Format(parser.Parse("-<num=-1.0>")));
+
+      // nested functions
+      Assert.AreEqual("SIN(SIN(SIN('X1')))", formatter.Format(parser.Parse("SIN(SIN(SIN(X1)))")));
     }
   }
Index: /branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs
===================================================================
--- /branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs	(revision 18174)
+++ /branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs	(revision 18175)
@@ -7,5 +7,4 @@
   [TestClass]
   public class BottomUpSimilarityCalculatorTest {
-    private readonly SymbolicExpressionImporter importer = new SymbolicExpressionImporter();
     private readonly InfixExpressionParser parser = new InfixExpressionParser();
 
@@ -13,8 +12,4 @@
     private const int Rows = 1;
     private const int Columns = 10;
-
-    public BottomUpSimilarityCalculatorTest() {
-      var parser = new InfixExpressionParser();
-    }
 
     [TestMethod]
@@ -28,17 +23,17 @@
 
       TestMatchedNodes("1 - 1", "2 - 2", 0, strict: true);
-      TestMatchedNodes("1 - 1", "2 - 2", 4, strict: false); // 4, because of the way strings are parsed into trees by the infix parser
+      TestMatchedNodes("1 - 1", "2 - 2", 3, strict: false);
 
       TestMatchedNodes("2 - 1", "1 - 2", 2, strict: true);
-      TestMatchedNodes("2 - 1", "1 - 2", 4, strict: false);
+      TestMatchedNodes("2 - 1", "1 - 2", 3, strict: false);
 
-      TestMatchedNodes("(X1 * X2) + (X3 * X4)", "(X1 * X2) + (X3 * X4)", 7, strict: true);
-      TestMatchedNodes("(X1 * X2) + (X3 * X4)", "(X1 * X2) + (X3 * X4)", 7, strict: false);
+      TestMatchedNodes("X1 * X2 + X3 * X4", "X1 * X2 + X3 * X4", 7, strict: true);
+      TestMatchedNodes("X1 * X2 + X3 * X4", "X1 * X2 + X3 * X4", 7, strict: false);
 
-      TestMatchedNodes("(X1 * X2) + (X3 * X4)", "(X1 * X2) + (X5 * X6)", 3, strict: true);
-      TestMatchedNodes("(X1 * X2) + (X3 * X4)", "(X1 * X2) + (X5 * X6)", 3, strict: false);
+      TestMatchedNodes("X1 * X2 + X3 * X4", "X1 * X2 + X5 * X6", 3, strict: true);
+      TestMatchedNodes("X1 * X2 + X3 * X4", "X1 * X2 + X5 * X6", 3, strict: false);
 
-      TestMatchedNodes("(X1 * X2) + (X3 * X4)", "(X1 * X2) - (X5 * X6)", 3, strict: true);
-      TestMatchedNodes("(X1 * X2) + (X3 * X4)", "(X1 * X2) - (X5 * X6)", 3, strict: false);
+      TestMatchedNodes("X1 * X2 + X3 * X4", "X1 * X2 - X5 * X6", 3, strict: true);
+      TestMatchedNodes("X1 * X2 + X3 * X4", "X1 * X2 - X5 * X6", 3, strict: false);
 
       TestMatchedNodes("SIN(SIN(SIN(X1)))", "SIN(SIN(SIN(X1)))", 4, strict: true);
@@ -47,6 +42,6 @@
       TestMatchedNodes("SIN(SIN(SIN(X1)))", "COS(COS(COS(X1)))", 1, strict: true);
 
-      const string lhs = "(0.006153 + (X9 * X7 * X2 * 0.229506) + (X6 * X10 * X3 * 0.924598) + (X2 * X1 * 0.951272) + (X4 * X3 * 0.992570) + (X6 * X5 * 1.027299))";
-      const string rhs = "(0.006153 + (X10 * X7 * X2 * 0.229506) + (X6 * X10 * X3 * 0.924598) + (X2 * X1 * 0.951272) + (X4 * X3 * 0.992570) + (X6 * X5 * 1.027299))";
+      const string lhs = "0.006153 + X9 * X7 * X2 * 0.229506 + X6 * X10 * X3 * 0.924598 + X2 * X1 * 0.951272 + X4 * X3 * 0.992570 + X6 * X5 * 1.027299";
+      const string rhs = "0.006153 + X10 * X7 * X2 * 0.229506 + X6 * X10 * X3 * 0.924598 + X2 * X1 * 0.951272 + X4 * X3 * 0.992570 + X6 * X5 * 1.027299";
 
       TestMatchedNodes(lhs, lhs, 24, strict: true);
