Refactor internals of the parser.