Index: trunk/Nebulous/lib/Nebulous/Client.pm
===================================================================
--- trunk/Nebulous/lib/Nebulous/Client.pm	(revision 26022)
+++ trunk/Nebulous/lib/Nebulous/Client.pm	(revision 26292)
@@ -315,7 +315,7 @@
     my $locations;
     if (defined $vol_name) {
-        $locations = $self->find_instances($key, $vol_name);
+        $locations = $self->find_instances_for_cull($key, $vol_name);
     } else {
-        $locations = $self->find_instances($key);
+        $locations = $self->find_instances_for_cull($key);
     }
 
@@ -326,9 +326,36 @@
         return;
     }
-
-    my $uri = $self->delete_instance($key, @$locations[0]);
+    
+    # Calculate which is the best instance to remove. First, see if we have two copies
+    # on one volume, if so, delete the first of those copies. 
+    my $delete_index = -1;
+
+    for (my $i = 0 ; $i <= $#{ $locations }; $i++) {
+	for (my $j = $i + 1; $j <= $#{ $locations }; $j++) {
+	    if (@$locations[$i]->{vol_id} eq @$locations[$j]->{vol_id}) {
+		$delete_index = $i;
+	    }
+	}
+    }
+    # If we don't have two copies on one volume, see if we have two copies on a single 
+    # cabinet. If so, delete the first of those copies.
+    if ($delete_index == -1) {
+	for (my $i = 0 ; $i <= $#{ $locations }; $i++) {
+	    for (my $j = $i + 1; $j <= $#{ $locations }; $j++) {
+		if (@$locations[$i]->{cab_id} eq @$locations[$j]->{cab_id}) {
+		    $delete_index = $i;
+		}
+	    }
+	}
+    }
+    # Fail-safe. We didn't have any duplicates (the instances are "well-mixed"), so 
+    # delete the first.
+    if ($delete_index == -1) {
+	$delete_index = 0;
+    }    
+    my $uri = $self->delete_instance($key, @$locations[$delete_index]->{uri});
 
     eval {
-        _nuke_file(_get_file_path(@$locations[0]));
+        _nuke_file(_get_file_path(@$locations[$delete_index]->{uri}));
     };
     if ($@) {
@@ -758,4 +785,47 @@
 }
 
+sub find_instances_for_cull
+{
+    my $self = shift;
+
+    my ( $key, @params ) = validate_pos( @_,
+        {
+            type        => SCALAR,
+        },
+        {
+            #volume
+            type        => SCALAR|UNDEF,
+            optional    => 1,
+        },
+    );
+
+    $log->debug( "entered - @_" );
+
+    my $response = $self->{ 'server' }->find_instances_for_cull( $key, @params );
+    if ( $response->fault ) {
+        $self->set_err($response->faultstring);
+        # check to see if this failure is because $key doesn't exist
+        if ($response->faultstring =~ /is valid object key/) {
+            $log->debug( "leaving" );
+            return;
+        }
+        # key is valid but no instances are on the specified volume
+        if ($response->faultstring =~ /no instances on storage volume/) {
+            $log->debug( "leaving" );
+            return;
+        }
+
+        $log->logdie("unhandled fault - ", $self->err);
+    }
+
+    my $uris = $response->result;
+
+    $log->debug( "server found: @$uris" );
+
+    $log->debug( "leaving" );
+
+    return $uris;
+}
+
 
 sub find
