Some minor changes to the cleanup loop (added it for the first time now)