fix high-iteration stack overflow by flattening the list

The core loop had too many generators: chaining them together results in high stack usage (and reduced speed) when called with a high number of iterations. At roughly 88000 iterations, python segfaults.

Removing those extra stack frames also appears to speed up the loop by about 5%

This fixes #2.