Index: trunk/pstamp/scripts/detect_query_read
===================================================================
--- trunk/pstamp/scripts/detect_query_read	(revision 29129)
+++ trunk/pstamp/scripts/detect_query_read	(revision 29130)
@@ -164,5 +164,5 @@
     }
     elsif ($status == 219) {
-	@{ $colData{$col->{name}} } = map { "Not Set" } (0 .. $numRows - 1);
+	@{ $colData{$col->{name}} } = map { "Not_Set" } (0 .. $numRows - 1);
 	$status = 0;
     }
@@ -173,12 +173,12 @@
 # Simple stuff first.
     my %known_filters = ();
-    if ($colData{STAGE}[$i] eq "Not Set") {
+    if ($colData{STAGE}[$i] eq "Not_Set") {
 	$colData{STAGE}[$i] = 'diff';
     }
-    if ($colData{OBSCODE}[$i] eq "Not Set") {
+    if ($colData{OBSCODE}[$i] eq "Not_Set") {
 	$colData{OBSCODE}[$i] = 566;
     }
 # Define filter and MJD from FPA_ID
-    if (($colData{FILTER}[$i] eq "Not Set")&&($colData{FPA_ID}[$i] ne "Not Set")) {
+    if (($colData{FILTER}[$i] eq "Not_Set")&&($colData{FPA_ID}[$i] ne "Not_Set")) {
 	if (exists($known_filters{$colData{FPA_ID}[$i]})) {
 	    $colData{FILTER}[$i] = $known_filters{$colData{FPA_ID}[$i]};
@@ -210,5 +210,5 @@
 	}
     }
-    if (($colData{'MJD-OBS'}[$i] eq "Not Set")&&($colData{FPA_ID}[$i] ne "Not Set")) {
+    if (($colData{'MJD-OBS'}[$i] eq "Not_Set")&&($colData{FPA_ID}[$i] ne "Not_Set")) {
 	# HACK!
 	my $mjd = $colData{FPA_ID}[$i];
@@ -217,6 +217,6 @@
 	$colData{'MJD-OBS'}[$i] = $mjd;
     }
-    if (($colData{FPA_ID}[$i] eq "Not Set")&&(($colData{'FILTER'}[$i] ne "Not Set")&&
-					      ($colData{'MJD-OBS'}[$i] ne "Not Set"))) {
+    if (($colData{FPA_ID}[$i] eq "Not_Set")&&(($colData{'FILTER'}[$i] ne "Not_Set")&&
+					      ($colData{'MJD-OBS'}[$i] ne "Not_Set"))) {
 	my $dateobs_begin = mjd_to_dateobs($colData{'MJD-OBS'}[$i]);
 	my $dateobs_end = mjd_to_dateobs($colData{'MJD-OBS'}[$i] + 1);
Index: trunk/pstamp/scripts/detectability_respond.pl
===================================================================
--- trunk/pstamp/scripts/detectability_respond.pl	(revision 29129)
+++ trunk/pstamp/scripts/detectability_respond.pl	(revision 29130)
@@ -91,8 +91,8 @@
     print "Reading wisdom file $wisdom_file instead of parsing...\n";
     open(WISDOM,"$wisdom_file") or my_die("failed to open wisdom file $wisdom_file");
-    my $i = 0;
     while(<WISDOM>) {
 	chomp;
 	my ($fpa_id,@key_values) = split /\s+/;
+	my $index = $#{ $query{$fpa_id}{ROWNUM} } + 1;
 	while ($#key_values > -1) {
 	    my $key = shift(@key_values);
@@ -102,7 +102,6 @@
 		$val = 0;
 	    }
-	    $query{$fpa_id}{$key}[$i] = $val;
-	}
-	$i++;
+	    $query{$fpa_id}{$key}[$index] = $val;
+	}
     }
     close(WISDOM);
@@ -150,52 +149,32 @@
 	my $filter;
 	my $mjd;
-	# Determine the query style for this fpa_id
-	if ($fpa_id =~ /o.*g.*o/) {
-	    $query_style = 'byexp';
-	}
-	elsif ($fpa_id =~ /\d+/) {
-	    $query_style = 'byid';
-	}
-	else {
-	    exit_with_failure(21,"Parse error in request file");
-	}
 	# Confirm that we only have one stage/filter/mjd
-	for (my $i = 0; $i <= $#{ $query{$fpa_id}{STAGE} }; $i++) {
-	    $temp_hash{STAGE}{$query{$fpa_id}{STAGE}[$i]} = 1;
-	    $temp_hash{FILTER}{$query{$fpa_id}{FILTER}[$i]} = 1;
-	    $temp_hash{'MJD-OBS'}{$query{$fpa_id}{'MJD-OBS'}[$i]} = 1;
-	}
-	if (scalar(keys(%{ $temp_hash{STAGE} })) == 1) {
-	    $stage = (keys(%{ $temp_hash{STAGE} }))[0];
-	}
-	else {
-	    exit_with_failure(21,"Too many STAGEs specified");
-	}
-	if (scalar(keys(%{ $temp_hash{FILTER} })) == 1) {
-	    $filter = (keys(%{ $temp_hash{FILTER} }))[0];
-	}
-	else {
-	    exit_with_failure(21,"Too many FILTERs specified");
-	}
-	if (scalar(keys(%{ $temp_hash{'MJD-OBS'} })) == 1) {
-	    $mjd = (keys(%{ $temp_hash{'MJD-OBS'} }))[0];
-	}
-	else {
-	    exit_with_failure(21,"Too many MJD-OBS specified");
-	}
-	# Set common request components
-	my $option_mask |= 1;
-	$option_mask |= $PSTAMP_SELECT_IMAGE;
-	$option_mask |= $PSTAMP_SELECT_MASK;
-	$option_mask |= $PSTAMP_SELECT_VARIANCE;
-	$option_mask |= $PSTAMP_SELECT_PSF;
-	my $need_magic = 1;
-	if ($stage eq 'stack') {
-	    $need_magic = 0;
-	}
-	my $mjd_min = $mjd;
-	my $mjd_max = $mjd + 1;
-	
-	# Construct a row list. 
+	if ($fpa_id ne 'Not_Set') {   # We only need to check things that aren't the known odd case.
+	    for (my $i = 0; $i <= $#{ $query{$fpa_id}{STAGE} }; $i++) {
+		$temp_hash{STAGE}{$query{$fpa_id}{STAGE}[$i]} = 1;
+		$temp_hash{FILTER}{$query{$fpa_id}{FILTER}[$i]} = 1;
+		$temp_hash{'MJD-OBS'}{$query{$fpa_id}{'MJD-OBS'}[$i]} = 1;
+	    }
+	    if (scalar(keys(%{ $temp_hash{STAGE} })) == 1) {
+		$stage = (keys(%{ $temp_hash{STAGE} }))[0];
+	    }
+	    else {
+		exit_with_failure(21,"Too many STAGEs specified");
+	    }
+	    if (scalar(keys(%{ $temp_hash{FILTER} })) == 1) {
+		$filter = (keys(%{ $temp_hash{FILTER} }))[0];
+	    }
+	    else {
+		exit_with_failure(21,"Too many FILTERs specified");
+	    }
+	    if (scalar(keys(%{ $temp_hash{'MJD-OBS'} })) == 1) {
+		$mjd = (keys(%{ $temp_hash{'MJD-OBS'} }))[0];
+	    }
+	    else {
+		exit_with_failure(21,"Too many MJD-OBS specified");
+	    }
+	}
+
+	# Set up a rowList with default values
 	my @rowList;
 	for (my $i = 0; $i <= $#{ $query{$fpa_id}{STAGE} }; $i++) {
@@ -223,6 +202,32 @@
 	    $query{$fpa_id}{FAULT}[$i] = 'no_fault';
 	    $query{$fpa_id}{BURNTOOL_STATE}[$i] = 'no_btstate';
-
-	}
+	}
+
+	# Determine the query style for this fpa_id
+	if ($fpa_id =~ /o.*g.*o/) {
+	    $query_style = 'byexp';
+	}
+	elsif ($fpa_id =~ /\d+/) {
+	    $query_style = 'byid';
+	}
+	elsif ($fpa_id eq 'Not_Set') {
+	    next;
+	}
+	else {
+	    exit_with_failure(21,"Parse error in request file");
+	}
+	# Set common request components
+	my $option_mask |= 1;
+	$option_mask |= $PSTAMP_SELECT_IMAGE;
+	$option_mask |= $PSTAMP_SELECT_MASK;
+	$option_mask |= $PSTAMP_SELECT_VARIANCE;
+	$option_mask |= $PSTAMP_SELECT_PSF;
+	my $need_magic = 1;
+	if ($stage eq 'stack') {
+	    $need_magic = 0;
+	}
+	my $mjd_min = $mjd;
+	my $mjd_max = $mjd + 1;
+	
 	
 	# Call the PStamp code to find the images that contain the target on the given MJD in the specified filter.
@@ -321,5 +326,5 @@
 open(WISDOM,">$wisdom_file") or my_die("failed to open wisdom file $wisdom_file");
 foreach my $fpa_id (keys %query) {
-    for (my $i = 0; $i <= $#{ $query{$fpa_id}{STAGE} }; $i++) {
+    for (my $i = 0; $i <= $#{ $query{$fpa_id}{ROWNUM} }; $i++) {
 	print WISDOM "$fpa_id\t";
 	foreach my $key (keys %{ $query{$fpa_id} }) {
@@ -690,5 +695,5 @@
 	    $inHeader->{FPA_ID}->{value} = $fpa_id;
 	}
-
+	
 	push @{$colData{'ROWNUM'}}, @{ $query{$fpa_id}{ROWNUM} };
 	push @{$colData{'ERROR_CODE'}}, @{ $query{$fpa_id}{PROC_ERROR} };
