Improved error handling and visualization