Bug fix and moved serializer code around