Moved targetdirectory property to where it was called before