WIP: Make SequenceGenerator functional again.

This involves bunch of changes in the core to be reviewed by @bartvm.

This is work in progress: I have not yet even touched documentation, for instance. But most of the stuff is there.
Ok, sorry, that's late here and I misunderstood you. Now it sounds reasonable. 

Btw, currently we do not recurse into scan, so right now it would not work out.