Implement Serialization and Deserialization

Part of #35