Refactor some of the existing code in Parser