Index: trunk/cgi-bin/IPDB.pm
===================================================================
--- trunk/cgi-bin/IPDB.pm	(revision 745)
+++ trunk/cgi-bin/IPDB.pm	(revision 746)
@@ -2137,8 +2137,8 @@
 #     Convert leaf allocations into free blocks.
 #   clearpeer
-#     Keep subs of the original
-#     Convert assigned IPs from pools into subs.
-#     Convert unused IPs from pools into free blocks.
-#     Convert leaf allocations into free blocks.
+#     Keep subs of the original (if it was a container).
+#     Convert assigned IPs from the original pool into subs (if it was a pool).
+#     Convert unused IPs from the original pool into free blocks (if it was a pool).
+#     Delete all peers and their subs aside from the original.
 #   clearall
 #     Delete all peers, subs and IPs.
@@ -2272,5 +2272,5 @@
           $mfbsth->execute($binfo->{master_id}, $m_id) if $peertype eq 'mm';
           # capture block for return
-          push @retlist, { block => $peercidr, mtype => $disp_alloctypes{$peertype} };
+          push @retlist, { block => $peercidr, mdisp => $disp_alloctypes{$peertype}, mtype => $peertype };
         }
 
@@ -2301,5 +2301,5 @@
               undef, ($peercidr, 'm', $prime, $prime) ) if $binfo->{type} eq 'mm';
           # capture block for return
-          push @retlist, { block => $peercidr, mtype => $disp_alloctypes{$peertype} };
+          push @retlist, { block => $peercidr, mdisp => $disp_alloctypes{$peertype}, mtype => $peertype };
         }
         if ($args{scope} eq 'clearall') {
@@ -2346,5 +2346,5 @@
           $mfbsth->execute($binfo->{master_id}, $m_id) if $peertype eq 'mm';
           # capture block for return
-          push @retlist, { block => $peercidr, mtype => $disp_alloctypes{$peertype} };
+          push @retlist, { block => $peercidr, mdisp => $disp_alloctypes{$peertype}, mtype => $peertype };
         } # merge peers
         # update the primary allocation info.  Do this last so we don't stomp extra data-retrieval in the loop above
@@ -2363,5 +2363,5 @@
       if ($args{scope} eq 'keepall') {
         # Convert all mergeable allocations and subs to chunks of pool IP assignments
-        push @retlist, @{ _toPool($dbh, $prime, $newblock, $args{newtype}) };
+        push @retlist, @{ _toPool($dbh, $prime, $newblock, $args{newtype}, 1) };
 
       } elsif ($args{scope} =~ /^clear/) {
@@ -2374,5 +2374,5 @@
           _deleteCascade($dbh, $peer_id, 0);
           # Capture block for return
-          push @retlist, { block => $peercidr, mtype => $disp_alloctypes{$peertype} };
+          push @retlist, { block => $peercidr, mdisp => $disp_alloctypes{$peertype}, mtype => $peertype };
         }
         if ($args{scope} eq 'clearall') {
@@ -2385,5 +2385,6 @@
         } else {
           # Convert (subs of) self if not a leaf.
-          _toPool($dbh, $prime, $newblock, $args{newtype}) unless $binfo->{type} =~ /.[enr]/;
+          push @retlist, @{ _toPool($dbh, $prime, $newblock, $args{newtype}, 1) }
+              unless $binfo->{type} =~ /.[enr]/;
         } # scope ne 'clearall'
 
@@ -2393,5 +2394,5 @@
           next if $peer_id == $prime;  # don't delete the block we're turning into the pool allocation
           # Capture block for return
-          push @retlist, { block => $peercidr, mtype => $disp_alloctypes{$peertype} };
+          push @retlist, { block => $peercidr, mdisp => $disp_alloctypes{$peertype}, mtype => $peertype };
           next unless $peertype =~ /.[enr]/;
           # Don't need _deleteCascade(), since we'll just be deleting the freshly
@@ -2424,5 +2425,5 @@
         _deleteCascade($dbh, $peer_id, 0);
         # Capture block for return
-        push @retlist, { block => $peercidr, mtype => $disp_alloctypes{$peertype} };
+        push @retlist, { block => $peercidr, mdisp => $disp_alloctypes{$peertype}, mtype => $peertype };
       }
       # Delete any subs of $prime as well
