Improvements to error handling: