Index: trunk/psModules/src/objects/pmSourceMatch.c
===================================================================
--- trunk/psModules/src/objects/pmSourceMatch.c	(revision 27162)
+++ trunk/psModules/src/objects/pmSourceMatch.c	(revision 27165)
@@ -181,5 +181,5 @@
     for (int i = 0; i < numImages; i++) {
         psArray *sources = sourceArrays->data[i]; // Sources in image
-        if (!sources) {
+        if (!sources || sources->n == 0) {
             continue;
         }
@@ -615,11 +615,10 @@
     {
         psVector *num = psVectorAlloc(numImages, PS_TYPE_S32); // Number of stars per image
+        psVectorInit(num, 0);
         for (int i = 0; i < numStars; i++) {
             pmSourceMatch *match = matches->data[i]; // Matched stars
             for (int j = 0; j < match->num; j++) {
-                if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j] & PM_SOURCE_MATCH_MASK_PHOT) {
-                    continue;
-                }
                 int index = match->image->data.U32[j]; // Image index
+                psAssert(index >= 0 && index < numImages, "Bad index: %d", index);
                 num->data.S32[index]++;
             }
