HPCC-10552 First round of coverity related changes

Most of the changes are removing code that is never used, or unlikely to cause issues, but there are a couple of slightly more serious issues.

@richardkchapman, @jamienoss, @jakesmith please can you check each change carefully - I haven't yet run a full regression test, and I'm not convinced it would pick up all mistakes.