split parser and serializer prototypes and refactor