Move directory creation to free function.
Do not fetch target unless destination is writeable.