Internal parser refactorings and cleanups