Added slightly better error handling to the parser methods.