Populate pending job queue prior to cloning out the middles and outputs.

Some other bug fixes and refactor.
Most tests pass now, but three still fail.