Index: /trunk/tools/refstacktool
===================================================================
--- /trunk/tools/refstacktool	(revision 32479)
+++ /trunk/tools/refstacktool	(revision 32480)
@@ -103,9 +103,21 @@
 my $n_exps = 0;
 my $exp_id_last = 0;
+
+my %exp_hash;
 while (my $exp = $stmt->fetchrow_hashref()) {
     # avoid exposures processed multiple times
     my $exp_id = $exp->{exp_id};
-    next if $exp_id_last == $exp_id;
+
+    if ($exp_hash{$exp_id}) {
+#        print "skipping duplicate for $exp_id\n";
+        next;
+    }
+#    This doesn't work since we are ordered by fwhm_major
+#    if ($exp_id_last == $exp_id) {
+#        print "skipping duplicate for $exp_id\n";
+#    }
     $exp_id_last = $exp_id;
+
+    $exp_hash{$exp_id} = 1;
 
     $n_exps++;
