anchor.diff:            TypeMirror listMirror = reflectType(List);
             TypeMirror mapMirror = reflectType(Map);
   
  -          // TODO: Use same type check here as we do in decode?
  -          //
  -          //       if(mirror.isSubtypeOf(VaneModelMember.listMirrorT) == true ||
  -          //          mirror.isSubtypeOf(VaneModelMember.mapMirrorT) == true) {
  -          //
  -
  +          // Remove Polymer Observable prefix if present
  +          String kv = symbolString(key);
  +          if(kv.startsWith("__\$")) {
  +            kv = kv.substring(3);
  +          }
  +
  +          // Check type
             if(VMMS.isBasicType(val.type.reflectedType) ||
  -//          if(val.type.reflectedType == String ||
  -//             val.type.reflectedType == int ||
  -//             val.type.reflectedType == bool ||
  -//             val.type.reflectedType == num ||
                val.type.isAssignableTo(listMirror) ||
                val.type.isAssignableTo(mapMirror)) {
  -            String mapKey = symbolString(key);
  -
  -            // Add value to map, remove Polymer Observable prefix if present
  -            if(mapKey.startsWith("__\$")) {
  -              map[mapKey.substring(3)] = mirror.getField(key).reflectee;
  +            // Add value to map
  +            map[kv] = mirror.getField(key).reflectee;
  +
  +            // TODO: Add special case for DateTime and Duration....
  +
  +          } else {
  +            // Add value to map
  +            map[kv] = modelToDocument(mirror.getField(key).reflectee);
  +          }
  +        }
  +      });
  +
  +      return map;
  +    }
  +
  +    // Run modelToDocument, will run recursively on object if needed
  +    return modelToDocument(this);
  +  }
  +
  +  /// Generate code for transformer
  +  static String transform(Object model) {
  +    // Function to generate code to for json generation
  +    StringBuffer modelToCode(Object model, StringBuffer code, bool fromDocument) {
  +      InstanceMirror mirror = reflect(model);
  +      String Model;
  +
  +      if(fromDocument == true) {
  +        // Create an easier to use variable for the model name
  +        Model = symbolString(mirror.type.simpleName);
  +
  +        // Check if we should use empty or model constructor
  +        int constructor = VaneModelMirror.constructorTypeOnClassMirror(mirror.type);
  +
  +        code.writeln('  bool useMirrors() => false;\n');
  +        code.writeln('  ${Model} fromDocument(Map document) {');
  +        if(constructor == EMPTY_CONSTRUCTOR) {
  +          code.writeln('    ${Model} This = new ${Model}();');
  +        } else if(constructor == MODEL_CONSTRUCTOR) {
  +          code.writeln('    ${Model} This = new ${Model}.model();');
  +        } else {
  +          throw new Exception("All VaneModels must have either an empty default constructor or empty \".model\" constructor, please add \"${Model}.model();\" to your model");
  +        }
  +      } else {
  +        code.writeln('  Map toJson() {');
  +        code.writeln('    Map map = new Map();');
  +      }
  +
  +      // For each model member
  +      mirror.type.declarations.forEach((Symbol key, DeclarationMirror val) {
  +        if(val is VariableMirror) {
  +          TypeMirror listMirror = reflectType(List);
  +          TypeMirror mapMirror = reflectType(Map);
  +
  +          // Remove Polymer Observable prefix if present
  +          String kv = symbolString(key);
  +          if(kv.startsWith("__\$")) {
  +            kv = kv.substring(3);
  +          }
  +
  +          // Check type
  +          if(VMMS.isBasicType(val.type.reflectedType)) {
  +            if(fromDocument == true) {
  +              // Write code
  +              code.writeln('    This.${kv} = document["${kv}"];');
               } else {
                 // Add value to map
  -              map[mapKey] = mirror.getField(key).reflectee;
  +              code.writeln('    map["${kv}"] = this.${kv};');
               }
  -
  -            // TODO: Add special case for DateTime ?!?!
  +          } else if(val.type.isAssignableTo(listMirror)) {
  +             if(fromDocument == true) {
  +               // Check what type of list
  +               if(VMMS.isBasicType(val.type.typeArguments[0].reflectedType)) {
  +//                 print("Found typed basic list!");
  +                 code.writeln('    if(This.${kv} == null) {');
  +                 code.writeln('      This.${kv} = new List();');
  +                 code.writeln('    }');
  +                 code.writeln('    This.${kv}.addAll(document["${kv}"]);');
  +               } else if(val.type.typeArguments[0] != VMMS.typeMirrorDynamic) {
  +//                 print("Found typed model based list!");
  +                 // Check if we should use empty or model constructor
  +                 int constructor = VaneModelMirror.constructorTypeOnClassMirror(val.type.typeArguments[0]);
  +
  +                 code.writeln('    if(This.${kv} == null) {');
  +                 code.writeln('      This.${kv} = new List();');
  +                 code.writeln('    }');
  +                 if(constructor == EMPTY_CONSTRUCTOR) {
  +                   code.writeln('    This.${kv}.addAll(document["${kv}"].map((doc) => VaneModel.decode(doc, new ${val.type.typeArguments[0].reflectedType}())));');
  +                 } else if(constructor == MODEL_CONSTRUCTOR) {
  +                   code.writeln('    This.${kv}.addAll(document["${kv}"].map((doc) => VaneModel.decode(doc, new ${val.type.typeArguments[0].reflectedType}.model())));');
  +                 } else {
  +                   throw new Exception("All VaneModels must have either an empty default constructor or empty \".model\" constructor, please add \"${kv}.model();\" to your model");
  +                 }
  +               } else {
  +//                 print("Found dynamic list!");
  +                 // Since we don't know the type we don't try to create new
  +                 // instances for items
  +                 code.writeln('    if(This.${kv} == null) {');
  +                 code.writeln('      This.${kv} = new List();');
  +                 code.writeln('    }');
  +                 code.writeln('    This.${kv}.addAll(document["${kv}"]);');
  +               }
  +             } else {
  +               // Add value to map
  +               code.writeln('    map["${kv}"] = this.${kv};');
  +             }
  +          } else if(val.type.isAssignableTo(mapMirror)) {
  +             if(fromDocument == true) {
  +               // Check what type of map
  +               if(VMMS.isBasicType(val.type.typeArguments[1].reflectedType)) {
  +//                 print("Found typed basic map!");
  +                 code.writeln('    if(This.${kv} == null) {');
  +                 code.writeln('      This.${kv} = new Map();');
  +                 code.writeln('    }');
  +                 code.writeln('    This.${kv}.addAll(document["${kv}"]);');
  +               } else if(val.type.typeArguments[0] != VMMS.typeMirrorDynamic) {
  +//                 print("Found typed model based map!");
  +                 // Check if we should use empty or model constructor
  +                 int constructor = VaneModelMirror.constructorTypeOnClassMirror(val.type.typeArguments[1]);
  +
  +                 code.writeln('    if(This.${kv} == null) {');
  +                 code.writeln('      This.${kv} = new Map();');
  +                 code.writeln('    }');
  +
  +                 if(constructor == EMPTY_CONSTRUCTOR) {
  +                   code.writeln('    document["${kv}"].forEach((key, doc) => This.m2[key] = VaneModel.decode(doc, new ${val.type.typeArguments[1].reflectedType}()));');
  +                 } else if(constructor == MODEL_CONSTRUCTOR) {
  +                   code.writeln('    document["${kv}"].forEach((key, doc) => This.m2[key] = VaneModel.decode(doc, new ${val.type.typeArguments[1].reflectedType}.model()));');
  +                 } else {
  +                   throw new Exception("All VaneModels must have either an empty default constructor or empty \".model\" constructor, please add \"${kv}.model();\" to your model");
  +                 }
  +               } else {
  +//                 print("Found dynamic map!");
  +                 // Since we don't know the type we don't try to create new
  +                 // instances for items
  +                 code.writeln('    if(This.${kv} == null) {');
  +                 code.writeln('      This.${kv} = new Map();');
  +                 code.writeln('    }');
  +                 code.writeln('    This.${kv}.addAll(document["${kv}"]);');
  +               }
  +             } else {
  +               // Add value to map
  +               code.writeln('    map["${kv}"] = this.${kv};');
  +             }
  +
  +            // TODO: Add special case for DateTime and Duration....
   
             } else {
  -            String mapKey = symbolString(key);
  -
  -            // Recursively add new map based on the member object, remove
  -            // Polymer Observable prefix if present
  -            if(mapKey.startsWith("__\$")) {
  -              map[mapKey.substring(3)] = modelToJson(mirror.getField(key).reflectee);
  +            if(fromDocument == true) {
  +              code.writeln('    This.${kv} = document["${kv}"];');
               } else {
  -              // Add value to map
  -              map[mapKey] = modelToJson(mirror.getField(key).reflectee);
  +              code.writeln('    map["${kv}"] = this.${kv};');
               }
             }
           }
         });
   
  -      return map;
  -    }
  -
  -    // Run objectToJson, will run recursively on object if needed
  -    return modelToJson(this);
  -  }
  -
  -
  -
  -
  +      if(fromDocument == true) {
  +        code.writeln('    return This;');
  +        code.writeln('  }\n');
  +      } else {
  +        code.writeln('    return map;');
  +        code.writeln('  }');
  +      }
  +
  +      return code;
  +    }
  +
  +    // String buffer used to store generated code
  +    StringBuffer code = new StringBuffer();
  +
  +    // Run modelToCode, will run recursively on object if needed
  +    code = modelToCode(model, code, true);
  +
  +    // Run modelToCode, will run recursively on object if needed
  +    code = modelToCode(model, code, false);
  +
  +    // Return the buffer as a string
  +    return code.toString();
  +  }
   }
   
   /// [ValidationException] is thrown if a class extending the [VaneModel] class
  
positive.code:   return symbol.toString().split('"')[1];
  }
  
  void transformP(String s) {
    bool doPrint;
  
    doPrint = false;
  //  doPrint = true;
  
    if(doPrint) {
      print(s);
    }
  }
  
  
  
negative.code:     */
    }
  
    /// Function used by transformer in order to tell VaneModel that code has
    /// been generated
    bool useMirrors() => true;
  
    static void _validateAny(model) {
      if(VMMS.isBasicType(model)) {
        // Validate built type
  