Optimization

Changing some iterators to go over integers rather than indexes. Saves
space.