Index: trunk/ppStack/src/ppStackSources.c
===================================================================
--- trunk/ppStack/src/ppStackSources.c	(revision 23195)
+++ trunk/ppStack/src/ppStackSources.c	(revision 23211)
@@ -110,5 +110,6 @@
         pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout
         pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image
-        pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i], NULL, NULL, psf, 5, 0, false, true);
+        pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i],
+                                 NULL, NULL, psf, 5, 0, false, true);
         psString name = NULL;
         psStringAppend(&name, "start_%03d.fits", i);
@@ -185,22 +186,24 @@
     psArray *sourcesBest = psArrayAllocEmpty (100);
 
-    // XXX something of a hack: require at 2 detections or 1/2 of the max possible
-    int minMatches = PS_MAX (2, 0.5*num);
+    // XXX something of a hack: require at least 2 detections or 1/2 of the max possible
+    int minMatches = PS_MAX(2, 0.3*num);// Minimum number of matches required
     for (int i = 0; i < matches->n; i++) {
         pmSourceMatch *match = matches->data[i]; // Match of interest
-        if (match->num < minMatches) continue;
+        if (match->num < minMatches) {
+            continue;
+        }
 
         // We need to grab a single instance of this source: just take the first available
-        int nImage = match->image->data.S32[0];
-        int nIndex = match->index->data.S32[0];
-        psArray *sources = sourceLists->data[nImage];
-        pmSource *source = sources->data[nIndex];
-
-        // stick this sample source on sourcesBest
-        psArrayAdd (sourcesBest, 100, source);
-    }
-    psMetadataAdd (sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, "psphot sources", sourcesBest);
-    psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis\n", sourcesBest->n);
-    psFree (sourcesBest);
+        int image = match->image->data.S32[0]; // Index of image
+        int index = match->index->data.S32[0]; // Index of source within image
+        psArray *sources = sourceLists->data[image]; // Sources for image
+        pmSource *source = sources->data[index]; // Source of interest
+
+        psArrayAdd(sourcesBest, 100, source);
+    }
+    psMetadataAdd(sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE,
+                  "psphot sources", sourcesBest);
+    psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis", sourcesBest->n);
+    psFree(sourcesBest);
 
     psFree(matches);
