add defensive check
move unused code into attic, good to save, just in case
oops, missed some more vars in the output!