HPCC-9853 Fix various warnings (a couple may have revealed minor bugs)

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