diff --git a/README.txt b/README.txt
index 918fc2a..42610a5 100644
--- a/README.txt
+++ b/README.txt
@@ -239,6 +239,9 @@ Do not use both types of declarations for a single project in your makefile.
   valid URL query string. Required.
 
   `filename` - What to name the file, if it's not an archive. Optional.
+  
+  `subtree` - if the download is an archive, only this subtree within the
+  archive will be copied to the target destination. Optional.
 
 - `download[type] = bzr`
 
diff --git a/drush_make.download.inc b/drush_make.download.inc
index 4187e89..c2859d7 100644
--- a/drush_make.download.inc
+++ b/drush_make.download.inc
@@ -67,7 +67,9 @@ function drush_make_download_file($name, $download, $download_location) {
       return FALSE;
     }
     drush_log(dt('%project downloaded from %url.', array('%project' => $name, '%url' => $download['url'])), 'ok');
-    return drush_make_download_file_unpack($filename, $download_location, (isset($download['filename']) ? $download['filename'] : ''));
+    $dl_fname = isset($download['filename']) ? $download['filename'] : '';
+    $subtree = isset($download['subtree']) ?  $download['subtree'] : NULL;
+    return drush_make_download_file_unpack($filename, $download_location, $dl_fname, $subtree);
   }
   drush_make_error('DOWNLOAD_ERROR', dt('Unable to download %project from %url.', array('%project' => $name, '%url' => $download['url'])));
   return FALSE;
@@ -239,37 +241,38 @@ function _drush_make_download_file($download) {
   return FALSE;
 }
 
-function drush_make_download_file_unpack($filename, $download_location, $name) {
+function drush_make_download_file_unpack($filename, $download_location, $name, $subtree = NULL) {
   $extension = array_pop(explode('.', $filename));
   switch ($extension) {
     case 'gz':
     case 'tgz':
       // I'd like to just use tar -z, but apparently it breaks on windoze. Why do they always have to ruin everything?
-      drush_make_download_file_unpack_gzip($filename, $download_location);
+      drush_make_download_file_unpack_gzip($filename, $download_location, $subtree);
       break;
     case 'tar':
-      drush_make_download_file_unpack_tar($filename, $download_location);
+      drush_make_download_file_unpack_tar($filename, $download_location, $subtree);
       break;
     case 'zip':
-      drush_make_download_file_unpack_zip($filename, $download_location);
+      drush_make_download_file_unpack_zip($filename, $download_location, $subtree);
       break;
     default:
       drush_shell_exec('mv %s %s', $filename, $download_location . ($name ? '/' . $name : ''));
   }
 }
 
-function drush_make_download_file_unpack_tar($filename, $download_location) {
-  $tmp_path = drush_make_tmp();
-
-  list($main_directory) = array_reverse(explode('/', $download_location));
-
-  drush_make_mkdir($tmp_path . '/__unzip__');
-  drush_shell_exec('tar -x -C %s -f %s', $tmp_path . '/__unzip__', $filename);
+function drush_make_download_file_unpack_tar($filename, $download_location, $subtree = NULL) {
+  $tmp_path = drush_make_tmp() . '/__untar__';
 
-  _drush_make_download_file_move($tmp_path, $filename, $download_location);
+  drush_make_mkdir($tmp_path);
+  drush_shell_exec('tar -x -C %s -f %s', $tmp_path, $filename);
+  
+  $src_path = isset($subtree) ? $tmp_path . '/' . $subtree : $tmp_path;
+  _drush_make_download_file_move($src_path, $download_location);
+  
+  drush_shell_exec('rm -rf %s', $tmp_path);
 }
 
-function drush_make_download_file_unpack_gzip($filename, $download_location) {
+function drush_make_download_file_unpack_gzip($filename, $download_location, $subtree = NULL) {
   // Find out where contents will end up. Retrieve last column of output using awk.
   drush_shell_exec("gzip --list %s", $filename);
   $info = drush_shell_exec_output();
@@ -285,49 +288,40 @@ function drush_make_download_file_unpack_gzip($filename, $download_location) {
     if (isset($file)) {
       // Unzip it and then delete the tar file.
       drush_shell_exec('gzip -d %s', $filename);
-      return drush_make_download_file_unpack_tar($file, $download_location);
+      return drush_make_download_file_unpack_tar($file, $download_location, $subtree);
     }
   }
   drush_make_error('PACKAGE_ERROR', dt('Could not retrieve package information for %filename.', array('%filename' => $filename)));
   return;
 }
 
-function drush_make_download_file_unpack_zip($filename, $download_location) {
-  $tmp_path = drush_make_tmp();
-
-  list($main_directory) = array_reverse(explode('/', $download_location));
+function drush_make_download_file_unpack_zip($filename, $download_location, $subtree = NULL) {
+  $tmp_path = drush_make_tmp() . '/__unzip__';
 
-  drush_make_mkdir($tmp_path . '/__unzip__');
-  drush_shell_exec("unzip %s -d %s", $filename, $tmp_path . '/__unzip__');
+  drush_make_mkdir($tmp_path);
+  drush_shell_exec("unzip %s -d %s", $filename, $tmp_path);
 
-  _drush_make_download_file_move($tmp_path, $filename, $download_location);
+  $src_path = isset($subtree) ? $tmp_path . '/' . $subtree : $tmp_path;
+  _drush_make_download_file_move($src_path, $download_location);
+  
+  drush_shell_exec('rm -rf %s', $tmp_path);
 }
 
-function _drush_make_download_file_move($tmp_path, $filename, $download_location) {
-  drush_shell_exec('ls %s', $tmp_path . '/__unzip__');
+function _drush_make_download_file_move($src_path, $download_location) {
+  $tmp_path = $src_path;
+  drush_shell_exec('ls %s', $tmp_path);
   $lines = drush_shell_exec_output();
   $main_directory = basename($download_location);
   if (count($lines) == 1) {
     $directory = array_shift($lines);
     if ($directory != $main_directory) {
-      drush_shell_exec('mv %s %s', $tmp_path . '/__unzip__/' . $directory, $tmp_path . '/__unzip__/' . $main_directory);
+      drush_shell_exec('mv %s %s', $tmp_path . '/' . $directory, $tmp_path . '/' . $main_directory);
     }
-    drush_shell_exec('cp -Rf %s %s', $tmp_path . '/__unzip__/' . $main_directory, dirname($download_location));
-    drush_shell_exec('rm -rf %s', $tmp_path . '/__unzip__');
-  }
-  elseif (count($lines) > 1) {
-    drush_shell_exec('rm -rf %s', $download_location);
-    drush_shell_exec('mv %s %s', $tmp_path . '/__unzip__', $download_location);
-  }
-
-  // Remove the tarball.
-  if (file_exists($filename)) {
-    drush_shell_exec('rm %s', $filename);
+    $tmp_path = $tmp_path . '/' . $main_directory;
   }
 
-  if (file_exists($tmp_path . '/__unzip__')) {
-    drush_shell_exec('rm -rf %s', $tmp_path . '/__unzip__');
-  }
+  drush_shell_exec('rm -rf %s', $download_location);
+  drush_shell_exec('mv %s %s', $tmp_path, $download_location);
 }
 
 
