Cleanup of code.  Including removing tmp file proliferation.