Moved serializer code to serializer.