Small simplifications and optimizations.

Generators are faster than lists when they're just meant to be iterated on once.