Improved error handling and output.