Fix serialization/deserialization to be backward compatible