--- original/gallery_assist.module	2010-02-17 04:38:14.000000000 +0100
+++ gallery_assist.module	2010-02-17 04:38:54.000000000 +0100
@@ -1418,7 +1418,7 @@ function gallery_assist_update($node) {
 
   // If the owner is changed.
   // Realize all nedded operations to assiggn all files and all galleries informations to the new owner.
-  if ($node->uid != $node->current_owner) {
+  if (!empty($node->current_owner) && $node->uid != $node->current_owner) {
     $user_gallery_directory = variable_get('gallery_assist_directory', file_directory_path() .'/gallery_assist') .'/'. $node->uid;
     
     
@@ -1430,7 +1430,6 @@ function gallery_assist_update($node) {
       gallery_assist_makedirs($node);
       if (count($node->gallery_items) > 0) {
         
-        $ganame = 'gallery_assist'. $node->ref;
         $old_path = "/$node->current_owner/";
         $new_path = "/$node->uid/";
 
@@ -1448,8 +1447,8 @@ function gallery_assist_update($node) {
         }
         
         // Scan for moving proccess.
-        $get_old_path = file_directory_path() .'/gallery_assist/'. $node->current_owner .'/'. $ganame;
-        $move_to_path = file_directory_path() .'/gallery_assist/'. $node->uid .'/'. $ganame;
+        $get_old_path = file_directory_path() .'/gallery_assist/'. $node->current_owner .'/'. $node->ganame;
+        $move_to_path = file_directory_path() .'/gallery_assist/'. $node->uid .'/'. $node->ganame;
         $scann = file_scan_directory($get_old_path, '.', array(), 0, TRUE);
 
         // Move the files to the new destination.
