Fixed handling of empty target-directory