Minor adjustments to error handling