Bugfixes to serializer