Added process.exit() after each error. Turned console logging into proper logfile logging.