diff --git a/commands/pm/package_handler/git_drupalorg.inc b/commands/pm/package_handler/git_drupalorg.inc
index fe933e8..d6bd787 100644
--- a/commands/pm/package_handler/git_drupalorg.inc
+++ b/commands/pm/package_handler/git_drupalorg.inc
@@ -190,7 +190,9 @@ function package_handler_post_download($project) {
 function drush_gitcache_check($gitcache) {
   if (is_dir(drush_server_home() . '/.drush')) {
     drush_mkdir($gitcache);
-    if (!drush_shell_cd_and_exec($gitcache, 'test $(git rev-parse --is-bare-repository) == "true"')) {
+    drush_shell_cd_and_exec($gitcache, 'git rev-parse --is-bare-repository');
+    $output = drush_shell_exec_output();
+    if (!isset($output[0]) || $output[0] != 'true') {
       drush_shell_cd_and_exec($gitcache, 'git init --bare');
       drush_shell_cd_and_exec($gitcache, 'git config core.compression 1');
     }
@@ -211,12 +213,13 @@ function drush_gitcache_add_project($gitcache, $request, $repository) {
   // On the first fetch, git will check for common commits with the remote
   // repository, so to speed this up we initially fetch from a local clone.
   $tmpdir = drush_tempdir();
-  $command = 'git clone --bare ';
+  $command = 'git clone --bare';
   if (drush_get_context('DRUSH_VERBOSE')) {
-    $command .= ' --verbose --progress ';
+    $command .= ' --verbose --progress';
   }
-  $command .= '%s';
+  $command .= ' %s';
   if (drush_shell_cd_and_exec($tmpdir, $command, $repository)) {
+    $tmpdir .= '/' . basename($repository);
     // Temporarily set the remote url to our temporary clone and fetch from there.
     drush_shell_cd_and_exec($gitcache, 'git remote add %s %s && git fetch %s --tags', $request['name'], $tmpdir, $request['name']);
 
diff --git a/examples/example.drushrc.php b/examples/example.drushrc.php
index 40fd2a0..b9e21dc 100644
--- a/examples/example.drushrc.php
+++ b/examples/example.drushrc.php
@@ -85,6 +85,24 @@
 // Specify Git clones for drupal.org extensions.
 # $options['package-handler'] = 'git_drupalorg';
 
+// Add a 'clone' Drush shell alias to simplify (cached) cloning from drupal.org.
+// Defaults to --dev; i.e., currently recommended development branch.
+# $options['shell-aliases']['clone'] = 'pm-download --package-handler=git_drupalorg --gitusername=sun --cache --dev';
+
+// Drush automatically determines the user's home directory by checking for HOME
+// (Unix) or HOMEDRIVE/HOMEPATH (Windows) environment variables. The home path
+// is used for caching Drush commands, and for the git --reference cache.
+// You may want to specify a path that is not user-specific here; e.g., to keep
+// cache files on the same filesystem, or to share caches with other users.
+# $options['home'] = 'H:/drush';
+
+// Drush automatically determines the temporary directory by checking /tmp or
+// sys_get_temp_dir() on Unix, or TEMP, TMP, WINDIR environment variables on
+// Windows. The temporary directory is used by various commands, including
+// package manager for downloading projects.
+// You may want to specify a path to keep temporary files on the same filesystem.
+# $options['temp'] = 'H:/drush';
+
 // Specify additional directories to search for *.drush.inc files
 // Separate by : (Unix-based systems) or ; (Windows).
 # $options['i'] = 'sites/default:profiles/myprofile';
diff --git a/includes/cache.inc b/includes/cache.inc
index 0119b9d..415e59b 100644
--- a/includes/cache.inc
+++ b/includes/cache.inc
@@ -378,12 +378,12 @@ class DrushFileCache implements DrushCacheInterface {
     $bin_dir = $this->cacheDirectory();
     $files = array();
     if (empty($cid)) {
-      drush_delete_dir($bin_dir);
+      drush_delete_dir($bin_dir, TRUE);
     }
     else {
       if ($wildcard) {
         if ($cid == '*') {
-          drush_delete_dir($bin_dir);
+          drush_delete_dir($bin_dir, TRUE);
         }
         else {
           $matches = drush_scan_directory($bin_dir, "/^$cid/", array('.', '..'));
diff --git a/includes/environment.inc b/includes/environment.inc
index d5d18ff..c315e67 100644
--- a/includes/environment.inc
+++ b/includes/environment.inc
@@ -647,7 +647,11 @@ function drush_is_local_host($host) {
  * Return the user's home directory.
  */
 function drush_server_home() {
-  $home = NULL;
+  // Allow to set $options['home'] in drushrc.php and on command line.
+  $home = drush_get_option('home');
+  if (isset($home)) {
+    return $home;
+  }
   // $_SERVER['HOME'] isn't set on windows and generates a Notice.
   if (!empty($_SERVER['HOME'])) {
     $home = $_SERVER['HOME'];
diff --git a/includes/filesystem.inc b/includes/filesystem.inc
index d544ac1..d0b0805 100644
--- a/includes/filesystem.inc
+++ b/includes/filesystem.inc
@@ -135,7 +135,7 @@ function drush_copy_dir($src, $dest, $overwrite = FALSE) {
   // Preflight based on $overwrite if $dest exists.
   if (file_exists($dest)) {
     if ($overwrite) {
-      drush_op('drush_delete_dir', $dest);
+      drush_op('drush_delete_dir', $dest, TRUE);
     }
     else {
       return drush_set_error('DRUSH_DESTINATION_EXISTS', dt('Destination directory !dest already exists.', array('!dest' => $dest)));
@@ -207,7 +207,7 @@ function drush_move_dir($src, $dest, $overwrite = FALSE) {
   // Preflight based on $overwrite if $dest exists.
   if (file_exists($dest)) {
     if ($overwrite) {
-      drush_op('drush_delete_dir', $dest);
+      drush_op('drush_delete_dir', $dest, TRUE);
     }
     else {
       return drush_set_error('DRUSH_DESTINATION_EXISTS', dt('Destination directory !dest already exists.', array('!dest' => $dest)));
@@ -234,7 +234,7 @@ function drush_move_dir($src, $dest, $overwrite = FALSE) {
   // If 'rename' fails, then we will use copy followed
   // by a delete of the source.
   if (drush_copy_dir($src, $dest)) {
-    drush_op('drush_delete_dir', $src);
+    drush_op('drush_delete_dir', $src, TRUE);
     return TRUE;
   }
 
@@ -278,11 +278,17 @@ function drush_save_data_to_temp_file($data) {
  * path is not valid in some setups for Mac.
  */
 function drush_find_tmp() {
-  static $temporary_directory = NULL;
+  static $temporary_directory;
 
-  if (is_null($temporary_directory)) {
+  if (!isset($temporary_directory)) {
     $directories = array();
 
+    // Allow to set $options['temp'] in drushrc.php and on command line.
+    $tempdir = drush_get_option('temp');
+    if (isset($tempdir)) {
+      $directories[] = $tempdir;
+    }
+
     // Operating system specific dirs.
     if (drush_is_windows()) {
       // get user specific and operating system temp folders from system environment variables
@@ -297,7 +303,7 @@ function drush_find_tmp() {
       }
       $windir = getenv('WINDIR');
       if (isset($windir)) {
-        $directories[] = $windir;
+        $directories[] = $windir . '/Temp';
       }
     }
     else {
@@ -388,7 +394,7 @@ function _drush_delete_registered_files() {
     // though they did not need to.
     if (file_exists($file)) {
       if (is_dir($file)) {
-        drush_delete_dir($file);
+        drush_delete_dir($file, TRUE);
       }
       else {
         @chmod($dir, 0777); // Make file writeable
