@hjoliver - is this code still needed, the only use I can find for it is in the commented out debugging code on lines 266 - 267 (could those be removed too?)