diff --git a/includes/file.inc b/includes/file.inc
index 40e8349..96ea615 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -849,6 +849,50 @@ function file_valid_uri($uri) {
  * @see file_copy()
  */
 function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
+  $destination = file_unmanaged_prepare_destination($source, $destination, $replace);
+   
+  // Perform the copy operation.
+  if (!@copy($source, $destination)) {
+    watchdog('file', 'The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination), WATCHDOG_ERROR);
+    return FALSE;
+  }
+
+  // Set the permissions on the new file.
+  drupal_chmod($destination);
+
+  return $destination;
+}
+
+/**
+ * Internal function that prepares the destination for a file_unmanaged_copy or file_unmanaged_move operation.
+ *
+ * - Checks if $source and $destination are valid and readable/writable.
+ * - Checks that $source is not equal to $destination; if they are an error
+ *   is reported.
+ * - If file already exists in $destination either the call will error out,
+ *   replace the file or rename the file based on the $replace parameter.
+ *
+ * @param $source
+ *   A string specifying the filepath or URI of the source file.
+ * @param $destination
+ *   A URI containing the destination that $source should be copied to. The
+ *   URI may be a bare filepath (without a scheme) and in that case the default
+ *   scheme (file://) will be used. If this value is omitted, Drupal's default
+ *   files scheme will be used, usually "public://".
+ * @param $replace
+ *   Replace behavior when the destination file already exists:
+ *   - FILE_EXISTS_REPLACE - Replace the existing file.
+ *   - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is
+ *       unique.
+ *   - FILE_EXISTS_ERROR - Do nothing and return FALSE.
+ *
+ * @return
+ *   The path to the new file to be moved or copied to, or FALSE in the event of an error.
+ *
+ * @see file_unmanaged_copy()
+ * @see file_unmanaged_move()
+ */
+function file_unmanaged_prepare_destination($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
   $original_source = $source;
   $original_destination = $destination;
 
@@ -905,15 +949,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
   }
   // Make sure the .htaccess files are present.
   file_ensure_htaccess();
-  // Perform the copy operation.
-  if (!@copy($source, $destination)) {
-    watchdog('file', 'The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination), WATCHDOG_ERROR);
-    return FALSE;
-  }
-
-  // Set the permissions on the new file.
-  drupal_chmod($destination);
-
+  
   return $destination;
 }
 
@@ -1066,11 +1102,24 @@ function file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS
  * @see file_move()
  */
 function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
-  $filepath = file_unmanaged_copy($source, $destination, $replace);
-  if ($filepath == FALSE || file_unmanaged_delete($source) == FALSE) {
+  $destination = file_unmanaged_prepare_destination($source, $destination, $replace);
+   
+  //Make sure that Drupal can move the file
+  $scheme = file_uri_scheme($source);
+  if ((!$scheme || !file_stream_wrapper_valid_scheme($scheme)) && (substr(PHP_OS, 0, 3) == 'WIN')) {
+    chmod($source, 0600);
+  }
+  
+  // Perform the rename operation.
+  if (!@rename($source, $destination)) {
+    watchdog('file', 'The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination), WATCHDOG_ERROR);
     return FALSE;
   }
-  return $filepath;
+
+  // Set the permissions on the new file.
+  drupal_chmod($destination);
+
+  return $destination;
 }
 
 /**
