Improve error handling and reported messages