More changes to serialization implementation. Unfinished.