Another round of improvements to error handling