Refactored some of the error handler to make the WHY more clear