Cleanup
Use midpoint iterator for initial generation
Merge branch 'optimize'