--- file_defer.module
+++ file_defer.module
@@ -26,7 +26,7 @@
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
   );
-  $items[$directory_path . '/%image_path'] = array(
+  $items[$directory_path] = array(
     'page callback' => 'file_defer_getfile',
     'access arguments' => array('access content'),
     'page arguments' => array(count(explode('/', $directory_path)) + 1),
@@ -63,7 +63,7 @@
   $scheme = array_shift($args);
   $filepath = implode('/', $args);
 
-  $directory = file_stream_wrapper_get_instance_by_scheme($scheme)->getDirectoryPath();
+  $directory = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath();
   if ($filepath = file_defer_downloadfile($directory, $filepath)) {
     // we just punt on the mime-type, the browser will just have to deal
     file_transfer($filepath, array('Content-Type: application/octet-stream ', 'Content-Length: ' . filesize($filepath)));
@@ -104,7 +104,7 @@
     $urls = explode("|", $urls);
     foreach ($urls as $url) {
       if ($url) {
-        $img = rtrim($url, "/") . '/' . $directory . '/' . $filepath;
+        $img = rtrim($url, "/") . '/' . $filepath;
         $img = str_replace(' ', '%20', $img);
         $outpath = $directory . "/" . $filepath;
         $directory = dirname($outpath);
@@ -114,7 +114,7 @@
             if ($fp = fopen($outpath, 'w')) {
               fwrite($fp, $result->data);
               fclose($fp);
-              return $outpath;
+              drupal_goto($outpath);
             }
           }
         }

