Did some cleanup, added logging of stat tracking.