fixes to error handling