Index: branches/New Persistence Exploration/Persistence/Persistence/Core/DeSerializer.cs
===================================================================
--- branches/New Persistence Exploration/Persistence/Persistence/Core/DeSerializer.cs	(revision 1433)
+++ branches/New Persistence Exploration/Persistence/Persistence/Core/DeSerializer.cs	(revision 1434)
@@ -5,5 +5,5 @@
 namespace HeuristicLab.Persistence.Core {  
 
-  struct ParentReference { }
+  public struct ParentReference {}
   delegate void Setter(object value);  
 
@@ -18,6 +18,8 @@
     }
 
-    public void AddValue(string name, object value) {
-      customValues.Add(new Tag(name, value));
+    public void AddValue(string name, object value, List<DeSerializer.Thunk> finalFixes) {
+      Tag t = new Tag(name, value);
+      t.finalFixes = finalFixes;
+      customValues.Add(t);
     }
 
@@ -31,5 +33,5 @@
 
     private delegate void Handler(ISerializationToken token);
-    private delegate void Thunk();
+    public delegate void Thunk();
 
     private readonly Dictionary<int, object> id2obj;
@@ -136,6 +138,6 @@
 
     private void NullHandler(ISerializationToken token) {
-      NullReferenceToken nil = (NullReferenceToken)token;
-      SetValue(nil.Name, null);
+      NullReferenceToken nullToken = (NullReferenceToken)token;
+      SetValue(nullToken.Name, null);
     }    
 
@@ -144,5 +146,5 @@
         parentStack.Push(new CompositeObject(value));
       } else {        
-        parentStack.Peek().AddValue(name, value);        
+        parentStack.Peek().AddValue(name, value, finalFixes);        
       }
     }
Index: branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/ArrayDecomposer.cs
===================================================================
--- branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/ArrayDecomposer.cs	(revision 1433)
+++ branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/ArrayDecomposer.cs	(revision 1434)
@@ -40,5 +40,6 @@
       int[] positions = new int[rank];
       while (e.MoveNext()) {
-        a.SetValue(e.Current.Value, positions);
+        int[] currentPositions = positions;
+        e.Current.SafeSet((value) => a.SetValue(value, currentPositions));        
         positions[0] += 1;
         for (int i = 0; i < rank-1; i++) {
Index: branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/DictionaryDecomposer.cs
===================================================================
--- branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/DictionaryDecomposer.cs	(revision 1433)
+++ branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/DictionaryDecomposer.cs	(revision 1434)
@@ -6,4 +6,36 @@
 
 namespace HeuristicLab.Persistence.Default.Decomposers {
+
+  class DictionaryAdder {
+
+    bool keyIsSet, valueIsSet;
+    object key;
+    object value;
+    IDictionary dict;
+
+    public DictionaryAdder(IDictionary dict) {
+      this.dict = dict;
+      keyIsSet = false;
+      valueIsSet = false;
+    }
+
+    public void SetKey(object value) {
+      key = value;
+      keyIsSet = true;
+      check();
+    }
+
+    public void SetValue(object value) {
+      this.value = value;
+      valueIsSet = true;
+      check();
+    }
+
+    private void check() {
+      if ( keyIsSet && valueIsSet )
+        dict.Add(key, value);
+    }
+
+  }
   
   public class DictionaryDecomposer : IDecomposer {
@@ -29,8 +61,10 @@
       IEnumerator<Tag> iter = o.GetEnumerator();
       while (iter.MoveNext()) {
-        object key = iter.Current.Value;
+        Tag key = iter.Current;
         iter.MoveNext();
-        object value = iter.Current.Value;
-        dict.Add(key, value);
+        Tag value = iter.Current;
+        DictionaryAdder da = new DictionaryAdder(dict);
+        key.SafeSet(da.SetKey);
+        value.SafeSet(da.SetValue);        
       }
       return dict;
Index: branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/EnumerableDecomposer.cs
===================================================================
--- branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/EnumerableDecomposer.cs	(revision 1433)
+++ branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/EnumerableDecomposer.cs	(revision 1434)
@@ -7,6 +7,8 @@
 
 namespace HeuristicLab.Persistence.Default.Decomposers {
-  
-  public class EnumerableDecomposer : IDecomposer {
+
+  public abstract class EnumerableDecomposer : IDecomposer {
+
+    public abstract void PerformAdd(object instance, MethodInfo addMethod, Tag tag);
 
     public bool CanDecompose(Type type) {
@@ -19,5 +21,5 @@
           BindingFlags.NonPublic |
           BindingFlags.Instance,
-          null, Type.EmptyTypes, null) != null;        
+          null, Type.EmptyTypes, null) != null;
     }
 
@@ -29,11 +31,11 @@
 
     public object CreateInstance(Type type) {
-      return Activator.CreateInstance(type, true);      
+      return Activator.CreateInstance(type, true);
     }
 
-    public object Populate(object instance, IEnumerable<Tag> objects, Type type) {
+    public object Populate(object instance, IEnumerable<Tag> tags, Type type) {
       MethodInfo addMethod = type.GetMethod("Add");
-      foreach (var pair in objects) {
-        addMethod.Invoke(instance, new[] {pair.Value});
+      foreach (var tag in tags) {
+        PerformAdd(instance, addMethod, tag);        
       }
       return instance;
@@ -42,3 +44,22 @@
   }
 
+  /// <summary>
+  /// Does never re-order elements but cannot reconstruct enumerables that directly
+  /// or indirectly contain references to not-yet-contructed parent objects (e.g. arrays).
+  /// </summary>
+  public class SafeEnumerableDecomposer : EnumerableDecomposer {
+    public override void PerformAdd(object instance, MethodInfo addMethod, Tag tag) {
+      addMethod.Invoke(instance, new[] { tag.Value });
+    }
+  }
+  /// <summary>
+  /// May re-order elements if the enumerable contains references to
+  /// not-yet-constructed parent objects (e.g. arrays).
+  /// </summary>
+  public class RobustEnumerableDecomposer : EnumerableDecomposer {
+     public override void PerformAdd(object instance, MethodInfo addMethod, Tag tag) {
+      tag.SafeSet((value) => addMethod.Invoke(instance, new[] { value }));
+    }    
+  }
+
 }
Index: branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/KeyValuePairDecomposer.cs
===================================================================
--- branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/KeyValuePairDecomposer.cs	(revision 1433)
+++ branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/KeyValuePairDecomposer.cs	(revision 1434)
@@ -5,4 +5,5 @@
 using HeuristicLab.Persistence.Core;
 using HeuristicLab.Persistence.Interfaces;
+using System.Reflection;
 
 namespace HeuristicLab.Persistence.Default.Decomposers {
@@ -23,5 +24,5 @@
 
     public object CreateInstance(Type type) {
-      return null;
+      return Activator.CreateInstance(type, true);
     }
 
@@ -29,8 +30,14 @@
       IEnumerator<Tag> iter = o.GetEnumerator();
       iter.MoveNext();
-      object key = iter.Current.Value;
+      FieldInfo keyFieldInfo =
+        t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
+        .Single((fi) => fi.Name == "key");
+      FieldInfo valueFieldInfo = 
+        t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
+        .Single((fi) => fi.Name == "value");
+      iter.Current.SafeSet((value) => keyFieldInfo.SetValue(instance, value));      
       iter.MoveNext();
-      object value = iter.Current.Value;
-      return Activator.CreateInstance(t, new object[] { key, value });      
+      iter.Current.SafeSet((value) => valueFieldInfo.SetValue(instance, value));
+      return instance;
     }    
   }
Index: branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/StorableDecomposer.cs
===================================================================
--- branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/StorableDecomposer.cs	(revision 1433)
+++ branches/New Persistence Exploration/Persistence/Persistence/Default/Decomposers/StorableDecomposer.cs	(revision 1434)
@@ -28,14 +28,15 @@
 
     public object Populate(object instance, IEnumerable<Tag> objects, Type type) {           
-      var memberDict = new Dictionary<string, object>();      
+      var memberDict = new Dictionary<string, Tag>();      
       IEnumerator<Tag> iter = objects.GetEnumerator();      
       while (iter.MoveNext()) {
-        memberDict.Add((string)iter.Current.Name, iter.Current.Value);
+        memberDict.Add((string)iter.Current.Name, iter.Current);
       }      
       foreach (var mapping in StorableAttribute.GetAutostorableAccessors(instance)) {
-        if ( memberDict.ContainsKey(mapping.Key) )
-          mapping.Value.Set(memberDict[mapping.Key]);
-        else if ( mapping.Value.DefaultValue != null )
+        if (memberDict.ContainsKey(mapping.Key)) {
+          memberDict[mapping.Key].SafeSet(mapping.Value.Set);
+        } else if (mapping.Value.DefaultValue != null) {
           mapping.Value.Set(mapping.Value.DefaultValue);
+        }
       }
       return instance;
Index: branches/New Persistence Exploration/Persistence/Persistence/Interfaces/IDecomposer.cs
===================================================================
--- branches/New Persistence Exploration/Persistence/Persistence/Interfaces/IDecomposer.cs	(revision 1433)
+++ branches/New Persistence Exploration/Persistence/Persistence/Interfaces/IDecomposer.cs	(revision 1434)
@@ -2,17 +2,26 @@
 using System.Collections;
 using System.Collections.Generic;
+using HeuristicLab.Persistence.Core;
 
 namespace HeuristicLab.Persistence.Interfaces {
 
-  public struct Tag {
-    public string Name;
-    public object Value;
+  public class Tag {
+    public List<DeSerializer.Thunk> finalFixes;
+    public string Name { get; private set; }
+    public object Value;      
+
     public Tag(string name, object value) {
-      Name = name;
-      Value = value;
+      this.Name = name;
+      this.Value = value;
     }
     public Tag(object value) {
-      Name = null;
-      Value = value;
+      this.Name = null;
+      this.Value = value;
+    }
+    public void SafeSet(DataMemberAccessor.Setter setter) {
+      if ( Value != null && Value.GetType() == typeof(ParentReference))
+        finalFixes.Add(() => setter(Value));
+      else
+        setter(Value);
     }
   }
Index: branches/New Persistence Exploration/Persistence/Test/NewSerializationTest.cs
===================================================================
--- branches/New Persistence Exploration/Persistence/Test/NewSerializationTest.cs	(revision 1433)
+++ branches/New Persistence Exploration/Persistence/Test/NewSerializationTest.cs	(revision 1434)
@@ -144,5 +144,11 @@
       return clone;
     }
-  }  
+  }
+
+  public class C {
+    [Storable]
+    public C[][] allCs;
+    public KeyValuePair<List<C>, C> kvpList;
+  }
 
   public class NewSerializationTest {
@@ -162,4 +168,18 @@
     }
 
+    public static void Test3() {
+      C c = new C();
+      C[][] cs = new C[2][];
+      cs[0] = new C[] { c };
+      cs[1] = new C[] { c };
+      c.allCs = cs;
+      c.kvpList = new KeyValuePair<List<C>, C>(new List<C> { c }, c);
+      XmlGenerator.Serialize(cs, "test3");
+      object o = XmlParser.DeSerialize("test3");
+      Console.Out.WriteLine(Util.AutoFormat(o, true));
+      Console.WriteLine(ViewOnlyGenerator.Serialize(cs));
+      Console.WriteLine(ViewOnlyGenerator.Serialize(o));
+    }
+
     public static void Test2() {
       Manager m = new Manager();      
@@ -190,7 +210,8 @@
 
 
-    public static void Main() {      
+    public static void Main() {            
       Test1();      
       //Test2();
+      Test3();
       //SpeedTest();
       //SpeedTest2();
