Index: trunk/psphot/src/psphotStackReadout.c
===================================================================
--- trunk/psphot/src/psphotStackReadout.c	(revision 34215)
+++ trunk/psphot/src/psphotStackReadout.c	(revision 34226)
@@ -286,11 +286,16 @@
     }
 
+    // gcc doesn't like the label to refer to a declaration so we declare this here
+    bool splitLinearFit;
+
 pass1finish:
 
-#ifdef notyet
-    // Split the fit of detected sources from matched sources. But not yet.
-    // NOTE: apply to ALL sources. Only include sources with postitive flux in the fit
-    psphotFitSourcesLinear (config, view, STACK_SRC, true, true); // pass 3 (detections->allSources)
-#endif
+    splitLinearFit = psMetadataLookupBool(NULL, recipe, "PSPHOT.STACK.SPLIT.LINEAR.FIT");
+    if (splitLinearFit) {
+        psLogMsg ("psphot", 3, "splitting fit of detected and matched soures\n");
+        // Fit the detected sources separately from matched that wea are about to create.
+        // NOTE: apply to ALL sources but only include sources with postitive flux in the fit
+        psphotFitSourcesLinear (config, view, STACK_SRC, true, true); // pass 3 (detections->allSources)
+    }
 
     // generate the objects (objects unify the sources from the different images) NOTE: could
@@ -300,4 +305,8 @@
     psMemDump("matchsources");
 
+    // check the source density. If it too high change the number of radial bins
+    // in the recipe.
+    psphotLimitRadialApertures(recipe, objects->n);
+
     // Construct an initial model for each object, set the radius to fitRadius, set circular
     // fit mask.  NOTE: only applied to sources without guess models
@@ -308,11 +317,12 @@
     psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects);
 
-#ifdef notyet
-    // NOTE: apply to Matched sources. Since the sources that we fit above are subtracted, they will
-    // not be included in this fit.
-    psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources)
-#else
-    psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 3 (detections->allSources)
-#endif
+    if (splitLinearFit) {
+        // NOTE: apply to Matched sources. Since the sources that we fit above are subtracted, they will
+        // not be included in this fit.
+        psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources)
+    } else {
+        // Fit all sources together
+        psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 3 (detections->allSources)
+    }
 
     // measure the radial profiles to the sky (only measures new objects)
