Some cleanup and logging.