Add factory method for serializer and deserializer