Move serialization/deserialization into own file.