HPCC-8316 Clean up the code to remove lots of workflow loops

Instead of applying each stage in turn to all the workflow items,
switch to walking through each workflow item and applying each stage
in turn.  It removes lots of loops.  It could also provide
scope for executing in parallel (although the benefits are likely to
be marginal for most queries).

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>