Log the iteration and some cleanups.