Fixed handling of directories with spaces