Fix/standardize some error handling