Cleanup serializer

Cleanup serializer code.

Pair programmed with @manuelmessner