reworked serialization/deserialization