Index: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs
===================================================================
--- branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs	(revision 16953)
+++ branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs	(revision 17035)
@@ -23,7 +23,7 @@
 using System.Collections.Generic;
 using System.Linq;
+using HEAL.Attic;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
-using HEAL.Attic;
 
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
@@ -38,32 +38,30 @@
 
     #region properties for separation between implementation and persistence
-    private List<Action> afterDeserializationActions = new List<Action>();
+    private IEnumerable<ISymbol> storableSymbols;
     [Storable(Name = "Symbols")]
     private IEnumerable<ISymbol> StorableSymbols {
       get { return symbols.Values.ToArray(); }
-      set { afterDeserializationActions.Add(() => { foreach (var s in value) symbols.Add(s.Name, s); }); }
-    }
-
+      set { storableSymbols = value; }
+    }
+
+    private IEnumerable<KeyValuePair<ISymbol, Tuple<int, int>>> storableSymbolSubtreeCount;
     [Storable(Name = "SymbolSubtreeCount")]
     private IEnumerable<KeyValuePair<ISymbol, Tuple<int, int>>> StorableSymbolSubtreeCount {
       get { return symbolSubtreeCount.Select(x => new KeyValuePair<ISymbol, Tuple<int, int>>(GetSymbol(x.Key), x.Value)).ToArray(); }
-      set { afterDeserializationActions.Add(() => { foreach (var pair in value) symbolSubtreeCount.Add(pair.Key.Name, pair.Value); }); }
-    }
-
+      set { storableSymbolSubtreeCount = value; }
+    }
+
+    private IEnumerable<KeyValuePair<ISymbol, IEnumerable<ISymbol>>> storableAllowedChildSymbols;
     [Storable(Name = "AllowedChildSymbols")]
     private IEnumerable<KeyValuePair<ISymbol, IEnumerable<ISymbol>>> StorableAllowedChildSymbols {
       get { return allowedChildSymbols.Select(x => new KeyValuePair<ISymbol, IEnumerable<ISymbol>>(GetSymbol(x.Key), x.Value.Select(GetSymbol).ToArray())).ToArray(); }
-      set { afterDeserializationActions.Add(() => { foreach (var pair in value) allowedChildSymbols.Add(pair.Key.Name, pair.Value.Select(y => y.Name).ToList()); }); }
-    }
-
+      set { storableAllowedChildSymbols = value; }
+    }
+
+    private IEnumerable<KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>> storableAllowedChildSymbolsPerIndex;
     [Storable(Name = "AllowedChildSymbolsPerIndex")]
     private IEnumerable<KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>> StorableAllowedChildSymbolsPerIndex {
       get { return allowedChildSymbolsPerIndex.Select(x => new KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>(Tuple.Create(GetSymbol(x.Key.Item1), x.Key.Item2), x.Value.Select(GetSymbol).ToArray())).ToArray(); }
-      set {
-        afterDeserializationActions.Add(() => {
-          foreach (var pair in value)
-            allowedChildSymbolsPerIndex.Add(Tuple.Create(pair.Key.Item1.Name, pair.Key.Item2), pair.Value.Select(y => y.Name).ToList());
-        });
-      }
+      set { storableAllowedChildSymbolsPerIndex = value; }
     }
     #endregion
@@ -91,4 +89,18 @@
 
       suppressEvents = false;
+    }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      foreach (var s in storableSymbols) symbols.Add(s.Name, s);
+      foreach (var pair in storableSymbolSubtreeCount) symbolSubtreeCount.Add(pair.Key.Name, pair.Value);
+      foreach (var pair in storableAllowedChildSymbols) allowedChildSymbols.Add(pair.Key.Name, pair.Value.Select(y => y.Name).ToList());
+      foreach (var pair in storableAllowedChildSymbolsPerIndex)
+        allowedChildSymbolsPerIndex.Add(Tuple.Create(pair.Key.Item1.Name, pair.Key.Item2), pair.Value.Select(y => y.Name).ToList());
+
+      storableSymbols = null;
+      storableSymbolSubtreeCount = null;
+      storableAllowedChildSymbols = null;
+      storableAllowedChildSymbolsPerIndex = null;
     }
 
