Refactor code to move parser into separate file for cleanliness