Adding better console output code and better error logging.