added initialise, shifted cleanup
added TARGET and TMPDIR vars