Simplify asserts.
Small simplifications and optimizations.

Generators are faster than lists when they're just meant to be iterated on once.
Merge pull request #27 from BertrandBordage/master

Simplifications