Implement serializer and deserializer