handle target_dir; remove obsolete code