Add partial serialization/deserialization
Minor improvements (courtesy hlint)