Improved error logging.