Improved error handling and clearer messages