Align serialization to work with Java implementation