PipelineIteration refactor.

Make PipelineIteration less dependent on the specifics of the stage it
is executing.
There are small number of TODOs which would be cleaned up in a
subsequent change