Code cleanups, replaced for loops with an iterator, etc...