Index: trunk/cgi-bin/IPDB.pm
===================================================================
--- trunk/cgi-bin/IPDB.pm	(revision 558)
+++ trunk/cgi-bin/IPDB.pm	(revision 559)
@@ -1119,17 +1119,4 @@
 #  'Net don't work like that, homey.  Restrict VRF-uniqueness to private IPs?
 # -> $isprivnet flag from start of sub
-
-      # if the block to be deleted is a container, move its freeblock(s) up a level, and reset their parenting info
-      if ($binfo->{type} =~ /^.[mc]/) {
-	# move the freeblocks into the parent
-	# we don't insert a new freeblock because there could be a live reparented sub.
-	$dbh->do("UPDATE freeblocks SET rdepth=rdepth-1,parent=?,routed=?,city=? ".
-		"WHERE parent=? AND rdepth=?", undef,
-		($parent, $ptype, $pcity, $cidr, $rdepth+1) );
-      } else {
-	# ... otherwise, add the freeblock
-	$dbh->do("INSERT INTO freeblocks (cidr, city, routed, parent, rdepth) VALUES (?,?,?,?,?)", undef,
-		($cidr, $pcity, $ptype, $parent, $rdepth) );
-      }
 
       my $fbrdepth = $rdepth;
@@ -1196,4 +1183,17 @@
 	# freeblocks in the identified parent to see if we can combine any of them.
 
+	# if the block to be deleted is a container, move its freeblock(s) up a level, and reset their parenting info
+	if ($binfo->{type} =~ /^.[mc]/) {
+	  # move the freeblocks into the parent
+	  # we don't insert a new freeblock because there could be a live reparented sub.
+	  $dbh->do("UPDATE freeblocks SET rdepth=rdepth-1,parent=?,routed=?,city=? ".
+		"WHERE parent=? AND rdepth=?", undef,
+		($parent, $ptype, $pcity, $cidr, $rdepth+1) );
+	} else {
+	  # ... otherwise, add the freeblock
+	  $dbh->do("INSERT INTO freeblocks (cidr, city, routed, parent, rdepth) VALUES (?,?,?,?,?)", undef,
+		($cidr, $pcity, $ptype, $parent, $rdepth) );
+	}
+
 ##fixme: vrf
 	# set up the query to get the list of blocks to try to merge.
