HPCC-12408 Various code generator optimizations

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
This assumes that expr is correctly link counted everywhere. Can we be sure that this is the case for this example?