Minor refactorings to the exception handling in parsing