Improved error handling and messages.