Some reworks to ease future transition to ES6 generators.

It will also helped to achieve more parallelism.