improved python shebangs and fixed broken handling of working directories when running programs