Index: trunk/ippScripts/scripts/magic_tree.pl
===================================================================
--- trunk/ippScripts/scripts/magic_tree.pl	(revision 18696)
+++ trunk/ippScripts/scripts/magic_tree.pl	(revision 18702)
@@ -64,5 +64,4 @@
 my $missing_tools;
 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
-my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
 if ($missing_tools) {
     warn("Can't find required tools.");
@@ -91,5 +90,5 @@
 
     foreach my $input ( @$inputs ) {
-        push @skycells, $input->{skycell_id};
+        push @skycells, $input->{node}; # NB: Storing the skycell_id in magicInputSkyfile.node
     }
 }
@@ -177,5 +176,5 @@
 };
 my @tasks = ( $root );
-while (scalar @tasks > 0) {
+while (scalar @tasks > 1) {
     my $node = shift @tasks;
     divide_node($node, \@tasks);
@@ -185,5 +184,5 @@
 my $mdcTree = print_node($root); # The tree in MDC format
 my ($treeFile, $treeName) = tempfile( "magictree.${magic_id}.XXXX", UNLINK => !$save_temps );
-print $treeFile, $mdcTree;
+print $treeFile $mdcTree;
 close $treeFile;
 
@@ -201,6 +200,5 @@
         unless ($success) {
             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-            warn("Unable to perform magictool -inputtree: $error_code");
-            exit($error_code);
+            &my_die("Unable to perform magictool -inputtree: $error_code", $magic_id, $error_code);
         }
     } else {
