Index: /branches/New Persistence Exploration/Persistence/Persistence/Core/DeSerializer.cs
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/Core/DeSerializer.cs	(revision 1436)
+++ /branches/New Persistence Exploration/Persistence/Persistence/Core/DeSerializer.cs	(revision 1437)
@@ -17,5 +17,5 @@
     }
 
-    public void AddValue(string name, object value, List<DeSerializer.Thunk> finalFixes) {
+    public void AddValue(string name, object value, List<Thunk> finalFixes) {
       Tag t = new Tag(name, value);
       t.finalFixes = finalFixes;
@@ -23,18 +23,16 @@
     }
 
-    public Setter GetSetter(string name) {            
+    public Setter GetSetterForLastAddedValue(string name) {            
       Tag t = customValues[customValues.Count - 1];      
       return value => t.Value = value;
     }
-  }  
+  }
+
+  public delegate void Thunk();
 
   public class DeSerializer {
-
-    private delegate void Handler(ISerializationToken token);
-    public delegate void Thunk();
-
+    
     private readonly Dictionary<int, object> id2obj;
-    private readonly Dictionary<Type, object> serializerMapping;
-    private readonly Dictionary<Type, Handler> handlers;
+    private readonly Dictionary<Type, object> serializerMapping;    
     private readonly Stack<CompositeObject> parentStack;    
     private readonly Dictionary<int, Type> typeIds;    
@@ -45,14 +43,11 @@
       id2obj = new Dictionary<int, object>();
       parentStack = new Stack<CompositeObject>();
-      handlers = new Dictionary<Type, Handler> {
-                     {typeof (BeginToken), CompositeStartHandler},
-                     {typeof (EndToken), CompositeEndHandler},
-                     {typeof (PrimitiveToken), PrimitiveHandler},
-                     {typeof (ReferenceToken), ReferenceHandler},
-                     {typeof (NullReferenceToken), NullHandler}
-                   };      
       typeIds = new Dictionary<int, Type>();
-      serializerMapping = new Dictionary<Type, object>();
-      foreach ( var typeMapping in typeCache ) {
+      serializerMapping = createSerializers(typeCache);
+    }
+
+    private Dictionary<Type, object> createSerializers(IEnumerable<TypeMapping> typeCache) {
+      var serializerMapping = new Dictionary<Type, object>();
+      foreach (var typeMapping in typeCache) {
         Type type = Type.GetType(typeMapping.TypeName);
         typeIds.Add(typeMapping.Id, type);
@@ -62,4 +57,5 @@
         }
       }
+      return serializerMapping;
     }
 
@@ -67,5 +63,18 @@
       finalFixes = new List<Thunk>();      
       foreach (ISerializationToken token in tokens) {
-        handlers[token.GetType()].Invoke(token);
+        Type t = token.GetType();
+        if ( t == typeof(BeginToken) ) {
+          CompositeStartHandler((BeginToken)token);
+        } else if ( t == typeof(EndToken) ) {
+          CompositeEndHandler((EndToken) token);
+        } else if ( t == typeof(PrimitiveToken) ) {
+          PrimitiveHandler((PrimitiveToken) token);
+        } else if ( t == typeof(ReferenceToken) ) {
+          ReferenceHandler((ReferenceToken) token);
+        } else if (t == typeof(NullReferenceToken)) {
+          NullHandler((NullReferenceToken)token);
+        } else {
+          throw new ApplicationException("invalid token type");
+        }
       }
       foreach (Thunk fix in finalFixes) {
@@ -75,68 +84,57 @@
     }
 
-    private void CompositeStartHandler(ISerializationToken token) {
-      BeginToken start = (BeginToken)token;
-      object instance;      
-      Type type = typeIds[(int)start.TypeId];
+    private void CompositeStartHandler(BeginToken token) {      
+      Type type = typeIds[(int)token.TypeId];
       IDecomposer decomposer = null;
       if ( serializerMapping.ContainsKey(type) )
         decomposer = serializerMapping[type] as IDecomposer;      
-      if (decomposer != null) {        
-        instance = decomposer.CreateInstance(type);
-        if (instance == null)
-          instance = new ParentReference();
-        parentStack.Push(new CompositeObject(instance));        
-      } else {
+      if (decomposer == null)
         throw new ApplicationException(String.Format(
           "No suitable method for deserialization of type \"{0}\" found.",
           type.VersionInvariantName()));
-      }
-      if ( start.Id != null )
-        id2obj.Add((int)start.Id, instance);
+      object instance = decomposer.CreateInstance(type);
+      if (instance == null)
+        instance = new ParentReference();
+      parentStack.Push(new CompositeObject(instance));              
+      if ( token.Id != null )
+        id2obj.Add((int)token.Id, instance);
     }
 
-    private void CompositeEndHandler(ISerializationToken token) {
-      EndToken end = (EndToken)token;
-      Type type = typeIds[(int)end.TypeId];
+    private void CompositeEndHandler(EndToken token) {      
+      Type type = typeIds[(int)token.TypeId];
       IDecomposer decomposer = null;
       if (serializerMapping.ContainsKey(type))
         decomposer = serializerMapping[type] as IDecomposer;            
-      if (decomposer != null) {
-        CompositeObject customComposite = (CompositeObject)parentStack.Pop();
-        object deserializedObject =          
-          decomposer.Populate(customComposite.Obj, customComposite.customValues, type);
-        if ( end.Id != null )
-          id2obj[(int)end.Id] = deserializedObject;        
-        SetValue(end.Name, deserializedObject);          
-      } else {
+      if (decomposer == null)
         throw new ApplicationException(String.Format(
           "No suitable method for deserialization of type \"{0}\" found.",
           type.VersionInvariantName()));
-      }
+      CompositeObject customComposite = (CompositeObject)parentStack.Pop();
+      object deserializedObject =          
+        decomposer.Populate(customComposite.Obj, customComposite.customValues, type);
+      if ( token.Id != null )
+        id2obj[(int)token.Id] = deserializedObject;        
+      SetValue(token.Name, deserializedObject);          
     }
 
-    private void PrimitiveHandler(ISerializationToken token) {
-      PrimitiveToken primitive = (PrimitiveToken)token;
-      Type type = typeIds[(int)primitive.TypeId];
-      object value = ((IFormatter) serializerMapping[type]).Parse(primitive.SerialData);
-      if ( primitive.Id != null )      
-        id2obj[(int)primitive.Id] = value;
-      SetValue(primitive.Name, value);
+    private void PrimitiveHandler(PrimitiveToken token) {      
+      Type type = typeIds[(int)token.TypeId];
+      object value = ((IFormatter) serializerMapping[type]).Parse(token.SerialData);
+      if ( token.Id != null )      
+        id2obj[(int)token.Id] = value;
+      SetValue(token.Name, value);
     }
 
-    private void ReferenceHandler(ISerializationToken token) {
-      ReferenceToken reference = (ReferenceToken)token;
-      object referredObject = id2obj[reference.Id];
-      SetValue(reference.Name, id2obj[reference.Id]);
+    private void ReferenceHandler(ReferenceToken token) {      
+      object referredObject = id2obj[token.Id];
+      SetValue(token.Name, referredObject);      
       if (referredObject is ParentReference) {
-        Setter set = parentStack.Peek().GetSetter(reference.Name);        
-        int id = reference.Id;
-        finalFixes.Add(() => set(id2obj[id]));
+        Setter set = parentStack.Peek().GetSetterForLastAddedValue(token.Name);                
+        finalFixes.Add(() => set(id2obj[token.Id]));
       } 
     }
 
-    private void NullHandler(ISerializationToken token) {
-      NullReferenceToken nullToken = (NullReferenceToken)token;
-      SetValue(nullToken.Name, null);
+    private void NullHandler(NullReferenceToken token) {      
+      SetValue(token.Name, null);
     }    
 
Index: /branches/New Persistence Exploration/Persistence/Persistence/Default/Xml/Compact/NumberArray2XmlFormatters.cs
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/Default/Xml/Compact/NumberArray2XmlFormatters.cs	(revision 1436)
+++ /branches/New Persistence Exploration/Persistence/Persistence/Default/Xml/Compact/NumberArray2XmlFormatters.cs	(revision 1437)
@@ -22,4 +22,8 @@
         sb.Append(a.GetLength(i));
       }
+      for (int i = 0; i < a.Rank; i++) {
+        sb.Append(Separator);
+        sb.Append(a.GetLowerBound(i));
+      }
       foreach (object o in a) {
         sb.Append(Separator);
@@ -41,5 +45,10 @@
         lengths[i] = int.Parse((string)values.Current);
       }
-      Array a = Array.CreateInstance(this.Type.GetElementType(), lengths);
+      int[] lowerBounds = new int[rank];
+      for (int i = 0; i < rank; i++) {
+        values.MoveNext();
+        lowerBounds[i] = int.Parse((string)values.Current);
+      }
+      Array a = Array.CreateInstance(this.Type.GetElementType(), lengths, lowerBounds);
       int[] positions = new int[rank];
       while (values.MoveNext()) {
Index: /branches/New Persistence Exploration/Persistence/Persistence/Default/Xml/XmlGenerator.cs
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/Default/Xml/XmlGenerator.cs	(revision 1436)
+++ /branches/New Persistence Exploration/Persistence/Persistence/Default/Xml/XmlGenerator.cs	(revision 1437)
@@ -139,5 +139,5 @@
 
     public static void Serialize(object o, string basename, Configuration configuration) {
-    Serializer s = new Serializer(o, configuration);
+      Serializer s = new Serializer(o, configuration);
       XmlGenerator xmlGenerator = new XmlGenerator();
       StreamWriter writer = new StreamWriter(basename + ".xml");
Index: /branches/New Persistence Exploration/Persistence/Persistence/Interfaces/IDecomposer.cs
===================================================================
--- /branches/New Persistence Exploration/Persistence/Persistence/Interfaces/IDecomposer.cs	(revision 1436)
+++ /branches/New Persistence Exploration/Persistence/Persistence/Interfaces/IDecomposer.cs	(revision 1437)
@@ -7,5 +7,5 @@
 
   public class Tag {
-    public List<DeSerializer.Thunk> finalFixes;
+    public List<Thunk> finalFixes;
     public string Name { get; private set; }
     public object Value;      
