Reduce memory consumption, optimize zipping/combining

Fixes #592 and #646.

The commit messages here should be relatively self-explanatory.

@indragiek @epatey