Index: /trunk/sources/HeuristicLab.GP.StructureIdentification/ModelAnalyzerExporter.cs
===================================================================
--- /trunk/sources/HeuristicLab.GP.StructureIdentification/ModelAnalyzerExporter.cs	(revision 1226)
+++ /trunk/sources/HeuristicLab.GP.StructureIdentification/ModelAnalyzerExporter.cs	(revision 1227)
@@ -48,5 +48,6 @@
     public string Export(IFunctionTree tree) {
       string result = ExportFunction(tree.Function, tree);
-      result += "(\n";
+      if(tree.SubTrees.Count>0) 
+        result += "(\n";
       foreach(IFunctionTree subTree in tree.SubTrees) {
         result += Export(subTree);
Index: /trunk/sources/HeuristicLab.GP/FunctionView.cs
===================================================================
--- /trunk/sources/HeuristicLab.GP/FunctionView.cs	(revision 1226)
+++ /trunk/sources/HeuristicLab.GP/FunctionView.cs	(revision 1227)
@@ -51,14 +51,7 @@
       representationsMenu.Text = "Tree representation";
       representationsMenu.Name = "Tree representation";
-      foreach(IFunctionTreeNameGenerator generator in allNameGenerators) {
-        MenuItem mi = new MenuItem(generator.Name, 
-          delegate(object source, EventArgs args) {
-            IFunctionTreeNameGenerator g = (IFunctionTreeNameGenerator)((MenuItem)source).Tag;
-            this.nameGenerator = g;
-            foreach(MenuItem otherMenuItem in representationsMenu.MenuItems) otherMenuItem.Checked = false;
-            ((MenuItem)source).Checked = true;
-            UpdateControls();
-          }, Shortcut.None);
-        if(generator is DefaultFunctionTreeNameGenerator) mi.Checked = true;
+      foreach (IFunctionTreeNameGenerator generator in allNameGenerators) {
+        MenuItem mi = new MenuItem(generator.Name, MakeNameGeneratorDelegate(generator), Shortcut.None);
+        if (generator is DefaultFunctionTreeNameGenerator) mi.Checked = true;
         else mi.Checked = false;
         mi.Tag = generator;
@@ -83,15 +76,11 @@
       DiscoveryService discoveryService = new DiscoveryService();
       IFunctionTreeExporter[] exporters = discoveryService.GetInstances<IFunctionTreeExporter>();
-      foreach(IFunctionTreeExporter exporter in exporters) {
+      foreach (IFunctionTreeExporter exporter in exporters) {
         string result;
         // register a menu item for the exporter
-        MenuItem item = new MenuItem("Copy to clip-board (" + exporter.Name + ")", 
-          delegate(object source, EventArgs args) {
-            TreeNode node = funTreeView.SelectedNode;
-            if(node == null || node.Tag == null) return;
-            Clipboard.SetText(exporter.Export((IFunctionTree)node.Tag));
-          }, Shortcut.None);
+        MenuItem item = new MenuItem("Copy to clip-board (" + exporter.Name + ")",
+          MakeExporterDelegate(exporter), Shortcut.None);
         // try to export the whole tree 
-        if(exporter.TryExport(functionTree, out result)) {
+        if (exporter.TryExport(functionTree, out result)) {
           // if it worked enable the context-menu item
           item.Enabled = true;
@@ -104,8 +93,26 @@
       funTreeView.Nodes.Add(rootNode);
 
-      foreach(IFunctionTree subTree in functionTree.SubTrees) {
+      foreach (IFunctionTree subTree in functionTree.SubTrees) {
         CreateTree(rootNode, subTree);
       }
       funTreeView.ExpandAll();
+    }
+
+    private EventHandler MakeNameGeneratorDelegate(IFunctionTreeNameGenerator generator) {
+      return delegate(object source, EventArgs args) {
+        IFunctionTreeNameGenerator g = (IFunctionTreeNameGenerator)((MenuItem)source).Tag;
+        this.nameGenerator = g;
+        foreach (MenuItem otherMenuItem in representationsMenu.MenuItems) otherMenuItem.Checked = false;
+        ((MenuItem)source).Checked = true;
+        UpdateControls();
+      };
+    }
+
+    private EventHandler MakeExporterDelegate(IFunctionTreeExporter exporter) {
+      return delegate(object source, EventArgs args) {
+        TreeNode node = funTreeView.SelectedNode;
+        if (node == null || node.Tag == null) return;
+        Clipboard.SetText(exporter.Export((IFunctionTree)node.Tag));
+      };
     }
 
@@ -117,5 +124,5 @@
       node.ContextMenu = treeNodeContextMenu;
       rootNode.Nodes.Add(node);
-      foreach(IFunctionTree subTree in functionTree.SubTrees) {
+      foreach (IFunctionTree subTree in functionTree.SubTrees) {
         CreateTree(node, subTree);
       }
@@ -127,5 +134,5 @@
       templateTextBox.Clear();
       editButton.Enabled = false;
-      if(funTreeView.SelectedNode != null && funTreeView.SelectedNode.Tag != null) {
+      if (funTreeView.SelectedNode != null && funTreeView.SelectedNode.Tag != null) {
         IFunctionTree selectedBranch = (IFunctionTree)funTreeView.SelectedNode.Tag;
         UpdateVariablesList(selectedBranch);
@@ -137,5 +144,5 @@
 
     private void UpdateVariablesList(IFunctionTree functionTree) {
-      foreach(IVariable variable in functionTree.LocalVariables) {
+      foreach (IVariable variable in functionTree.LocalVariables) {
         variablesListBox.Items.Add(variable.Name);
       }
@@ -144,8 +151,8 @@
     private void variablesListBox_SelectedIndexChanged(object sender, EventArgs e) {
       // in case we had an event-handler registered for a different variable => unregister the event-handler
-      if(selectedVariable != null) {
+      if (selectedVariable != null) {
         selectedVariable.Value.Changed -= new EventHandler(selectedVariable_ValueChanged);
       }
-      if(variablesListBox.SelectedItem != null) {
+      if (variablesListBox.SelectedItem != null) {
         string selectedVariableName = (string)variablesListBox.SelectedItem;
         selectedVariable = selectedBranch.GetLocalVariable(selectedVariableName);
@@ -162,5 +169,5 @@
 
     void selectedVariable_ValueChanged(object sender, EventArgs e) {
-      if(funTreeView.SelectedNode != null && funTreeView.SelectedNode.Tag != null) {
+      if (funTreeView.SelectedNode != null && funTreeView.SelectedNode.Tag != null) {
         TreeNode node = funTreeView.SelectedNode;
         node.Text = nameGenerator.GetName(functionTree);
@@ -173,5 +180,5 @@
 
     private void funTreeView_MouseUp(object sender, MouseEventArgs e) {
-      if(e.Button == MouseButtons.Right) {
+      if (e.Button == MouseButtons.Right) {
         // Select the clicked node
         funTreeView.SelectedNode = funTreeView.GetNodeAt(e.X, e.Y);
