Moved the old serializer code into its own class.