HPCC-9065 Restructure code while investigating optimization

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>