Add target_dir .
Refactoring: extract some methods.