Index: branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs
===================================================================
--- branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs	(revision 6618)
+++ branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs	(revision 6620)
@@ -21,9 +21,10 @@
 
 using System;
+using System.Collections.Generic;
 using System.Linq;
+using HeuristicLab.Collections;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using System.Collections.Generic;
 
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
@@ -120,5 +121,5 @@
     protected SymbolicExpressionGrammar(SymbolicExpressionGrammar original, Cloner cloner)
       : base(original, cloner) {
-      foreach (ISymbol symbol in Symbols)
+      foreach (ISymbol symbol in symbols.Values)
         RegisterSymbolEvents(symbol);
 
@@ -161,11 +162,13 @@
     }
 
-    protected override void AddSymbol(ISymbol symbol) {
+    protected override sealed void AddSymbol(ISymbol symbol) {
       base.AddSymbol(symbol);
       RegisterSymbolEvents(symbol);
-    }
-    protected override void RemoveSymbol(ISymbol symbol) {
+      OnChanged();
+    }
+    protected override sealed void RemoveSymbol(ISymbol symbol) {
       DeregisterSymbolEvents(symbol);
       base.RemoveSymbol(symbol);
+      OnChanged();
     }
 
@@ -231,11 +234,49 @@
 
     #region symbol events
-    protected virtual void RegisterSymbolEvents(ISymbol symbol) {
+    private void RegisterSymbolEvents(ISymbol symbol) {
       symbol.NameChanging += new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
       symbol.NameChanged += new EventHandler(Symbol_NameChanged);
-    }
-    protected virtual void DeregisterSymbolEvents(ISymbol symbol) {
+
+      var groupSymbol = symbol as GroupSymbol;
+      if (groupSymbol != null) RegisterGroupSymbolEvents(groupSymbol);
+      else symbol.Changed += new EventHandler(Symbol_Changed);
+    }
+    private void DeregisterSymbolEvents(ISymbol symbol) {
       symbol.NameChanging -= new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
       symbol.NameChanged -= new EventHandler(Symbol_NameChanged);
+
+      var groupSymbol = symbol as GroupSymbol;
+      if (groupSymbol != null) DeregisterGroupSymbolEvents(groupSymbol);
+      else symbol.Changed -= new EventHandler(Symbol_Changed);
+    }
+
+    private void RegisterGroupSymbolEvents(GroupSymbol groupSymbol) {
+      groupSymbol.Changed += new EventHandler(GroupSymbol_Changed);
+      groupSymbol.SymbolsCollection.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_ItemsAdded);
+      groupSymbol.SymbolsCollection.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_ItemsRemoved);
+      groupSymbol.SymbolsCollection.CollectionReset += new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_CollectionReset);
+    }
+    private void DeregisterGroupSymbolEvents(GroupSymbol groupSymbol) {
+      groupSymbol.Changed -= new EventHandler(GroupSymbol_Changed);
+      groupSymbol.SymbolsCollection.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_ItemsAdded);
+      groupSymbol.SymbolsCollection.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_ItemsRemoved);
+      groupSymbol.SymbolsCollection.CollectionReset -= new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_CollectionReset);
+    }
+
+    private void Symbol_Changed(object sender, EventArgs e) {
+      if (suppressEvents) return;
+      ClearCaches();
+      OnChanged();
+    }
+
+    private void GroupSymbol_Changed(object sender, EventArgs e) {
+      if (suppressEvents) return;
+      suppressEvents = true;
+      GroupSymbol groupSymbol = (GroupSymbol)sender;
+      foreach (ISymbol symbol in groupSymbol.Flatten())
+        symbol.Enabled = groupSymbol.Enabled;
+      suppressEvents = false;
+      ClearCaches();
+      OnChanged();
     }
 
@@ -280,4 +321,33 @@
 
       ClearCaches();
+      OnChanged();
+    }
+
+    private void GroupSymbol_ItemsAdded(object sender, CollectionItemsChangedEventArgs<ISymbol> e) {
+      suppressEvents = true;
+      foreach (ISymbol symbol in e.Items)
+        if (!ContainsSymbol(symbol))
+          AddSymbol(symbol);
+      suppressEvents = false;
+      OnChanged();
+    }
+    private void GroupSymbol_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<ISymbol> e) {
+      suppressEvents = true;
+      foreach (ISymbol symbol in e.Items)
+        if (ContainsSymbol(symbol))
+          RemoveSymbol(symbol);
+      suppressEvents = false;
+      OnChanged();
+    }
+    private void GroupSymbol_CollectionReset(object sender, CollectionItemsChangedEventArgs<ISymbol> e) {
+      suppressEvents = true;
+      foreach (ISymbol symbol in e.Items)
+        if (!ContainsSymbol(symbol))
+          AddSymbol(symbol);
+      foreach (ISymbol symbol in e.OldItems)
+        if (ContainsSymbol(symbol))
+          RemoveSymbol(symbol);
+      suppressEvents = false;
+      OnChanged();
     }
     #endregion
Index: branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
===================================================================
--- branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs	(revision 6618)
+++ branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs	(revision 6620)
@@ -23,5 +23,4 @@
 using System.Collections.Generic;
 using System.Linq;
-using HeuristicLab.Collections;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -127,5 +126,4 @@
       symbolSubtreeCount.Add(symbol.Name, Tuple.Create(0, 0));
       ClearCaches();
-      OnChanged();
     }
 
@@ -265,5 +263,5 @@
       var symbols = symbol.Flatten().Where(s => !(s is GroupSymbol));
       if (symbols.Any(s => s.MinimumArity > minimumSubtreeCount)) throw new ArgumentException("Invalid minimum subtree count " + minimumSubtreeCount + " for " + symbol);
-      if (symbols.Any(s => s.MaximumArity < maximumSubtreeCount)) throw new ArgumentException("Invalid minimum subtree count " + minimumSubtreeCount + " for " + symbol);
+      if (symbols.Any(s => s.MaximumArity < maximumSubtreeCount)) throw new ArgumentException("Invalid maximum subtree count " + maximumSubtreeCount + " for " + symbol);
 
       foreach (ISymbol s in symbols)
@@ -398,123 +396,4 @@
     }
 
-    #region events
-    private void RegisterSymbolEvents(ISymbol symbol) {
-      symbol.NameChanging += new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
-      symbol.NameChanged += new EventHandler(Symbol_NameChanged);
-
-      var groupSymbol = symbol as GroupSymbol;
-      if (groupSymbol != null) RegisterGroupSymbolEvents(groupSymbol);
-      else symbol.Changed += new EventHandler(Symbol_Changed);
-    }
-    private void DeregisterSymbolEvents(ISymbol symbol) {
-      symbol.NameChanging -= new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
-      symbol.NameChanged -= new EventHandler(Symbol_NameChanged);
-
-      var groupSymbol = symbol as GroupSymbol;
-      if (groupSymbol != null) DeregisterGroupSymbolEvents(groupSymbol);
-      else symbol.Changed -= new EventHandler(Symbol_Changed);
-    }
-
-    private void RegisterGroupSymbolEvents(GroupSymbol groupSymbol) {
-      groupSymbol.Changed += new EventHandler(GroupSymbol_Changed);
-      groupSymbol.SymbolsCollection.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_ItemsAdded);
-      groupSymbol.SymbolsCollection.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_ItemsRemoved);
-      groupSymbol.SymbolsCollection.CollectionReset += new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_CollectionReset);
-    }
-    private void DeregisterGroupSymbolEvents(GroupSymbol groupSymbol) {
-      groupSymbol.Changed -= new EventHandler(GroupSymbol_Changed);
-      groupSymbol.SymbolsCollection.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_ItemsAdded);
-      groupSymbol.SymbolsCollection.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_ItemsRemoved);
-      groupSymbol.SymbolsCollection.CollectionReset -= new Collections.CollectionItemsChangedEventHandler<ISymbol>(GroupSymbol_CollectionReset);
-    }
-
-    private void Symbol_NameChanging(object sender, CancelEventArgs<string> e) {
-      if (symbols.ContainsKey(e.Value)) e.Cancel = true;
-    }
-    private void Symbol_NameChanged(object sender, EventArgs e) {
-      ISymbol symbol = (ISymbol)sender;
-      string oldName = symbols.Where(x => x.Value == symbol).First().Key;
-      string newName = symbol.Name;
-
-      symbols.Remove(oldName);
-      symbols.Add(newName, symbol);
-
-      var subtreeCount = symbolSubtreeCount[oldName];
-      symbolSubtreeCount.Remove(oldName);
-      symbolSubtreeCount.Add(newName, subtreeCount);
-
-      List<string> allowedChilds;
-      if (allowedChildSymbols.TryGetValue(oldName, out allowedChilds)) {
-        allowedChildSymbols.Remove(oldName);
-        allowedChildSymbols.Add(newName, allowedChilds);
-      }
-
-      for (int i = 0; i < GetMaximumSubtreeCount(symbol); i++) {
-        if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(oldName, i), out allowedChilds)) {
-          allowedChildSymbolsPerIndex.Remove(Tuple.Create(oldName, i));
-          allowedChildSymbolsPerIndex.Add(Tuple.Create(newName, i), allowedChilds);
-        }
-      }
-
-      foreach (var parent in Symbols) {
-        if (allowedChildSymbols.TryGetValue(parent.Name, out allowedChilds))
-          if (allowedChilds.Remove(oldName))
-            allowedChilds.Add(newName);
-
-        for (int i = 0; i < GetMaximumSubtreeCount(parent); i++) {
-          if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, i), out allowedChilds))
-            if (allowedChilds.Remove(oldName)) allowedChilds.Add(newName);
-        }
-      }
-
-      ClearCaches();
-      OnChanged();
-    }
-
-    private void Symbol_Changed(object sender, EventArgs e) {
-      if (suppressEvents) return;
-      ClearCaches();
-      OnChanged();
-    }
-
-    private void GroupSymbol_Changed(object sender, EventArgs e) {
-      if (suppressEvents) return;
-      suppressEvents = true;
-      GroupSymbol groupSymbol = (GroupSymbol)sender;
-      foreach (ISymbol symbol in groupSymbol.Flatten())
-        symbol.Enabled = groupSymbol.Enabled;
-      suppressEvents = false;
-      ClearCaches();
-      OnChanged();
-    }
-
-    private void GroupSymbol_ItemsAdded(object sender, CollectionItemsChangedEventArgs<ISymbol> e) {
-      suppressEvents = true;
-      foreach (ISymbol symbol in e.Items)
-        if (!ContainsSymbol(symbol))
-          AddSymbol(symbol);
-      suppressEvents = false;
-      OnChanged();
-    }
-    private void GroupSymbol_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<ISymbol> e) {
-      suppressEvents = true;
-      foreach (ISymbol symbol in e.Items)
-        if (ContainsSymbol(symbol))
-          RemoveSymbol(symbol);
-      suppressEvents = false;
-      OnChanged();
-    }
-    private void GroupSymbol_CollectionReset(object sender, CollectionItemsChangedEventArgs<ISymbol> e) {
-      suppressEvents = true;
-      foreach (ISymbol symbol in e.Items)
-        if (!ContainsSymbol(symbol))
-          AddSymbol(symbol);
-      foreach (ISymbol symbol in e.OldItems)
-        if (ContainsSymbol(symbol))
-          RemoveSymbol(symbol);
-      suppressEvents = false;
-      OnChanged();
-    }
-
     public event EventHandler Changed;
     protected virtual void OnChanged() {
@@ -523,5 +402,4 @@
       if (handler != null) Changed(this, EventArgs.Empty);
     }
-    #endregion
   }
 }
