More tweaks to error handling