Add better support for serializing/deserializing immutable object