For each loops! Magnificent beasts.

Other small code improvements too.