Code improvements and updates to logging.