Code cleanup and logging.