fix target_dir parse; fix cleanup temp files