Added errors and logging.