Index: trunk/psphot/src/psphot.c
===================================================================
--- trunk/psphot/src/psphot.c	(revision 5980)
+++ trunk/psphot/src/psphot.c	(revision 5986)
@@ -1,4 +1,5 @@
 # include "psphot.h"
 
+// XXX need a better structure for handling optional sequence
 int main (int argc, char **argv) {
 
@@ -9,28 +10,16 @@
     pmPSF       *psf     = NULL;
     psStats     *sky     = NULL;
-    pmPSFClump   psfClump;
     bool         status;
 
     psTimerStart ("complete");
 
-    psphotModelGroupInit ();
-
+    // load command-line arguments and options
     config = psphotArguments (&argc, argv);
 
     // load input data (config and images (signal, noise, mask)
-    // XXX we have memory leaks here -- may be from psMetadata
     imdata = psphotSetup (config);
 
-    char *breakPt = psMetadataLookupPtr (&status, config, "BREAK_POINT");
-    if (!status) breakPt = psStringCopy ("NONE");
-
-    int FITMODE = psMetadataLookupS32 (&status, config, "FIT_MODE");
-    if (!status) FITMODE = 2;
-
-    // run model fitting tests on a single source
-    if (psMetadataLookupBool (&status, config, "TEST_FIT")) {
-	psphotModelTest (imdata, config);
-	exit (0);
-    }
+    // run a single-model test if desired
+    psphotModelTest (imdata, config);
 
     // measure image stats for initial guess 
@@ -42,31 +31,20 @@
 
     // find the peaks in the image
-    peaks = pmPeaksSigmaLimit (imdata, config, sky);
-    if (!strcasecmp (breakPt, "PEAKS")) exit (0);
+    peaks = psphotFindPeaks (imdata, config, sky);
 
     // construct sources and measure basic stats
     sources = psphotSourceStats (imdata, config, peaks);
-    if (!strcasecmp (breakPt, "STATS")) exit (0);
 
     // classify sources based on moments, brightness
-    // XXX - this has 1 leak
-    psfClump = pmSourcePSFClump (sources, config);
-
-    // group into STAR, COSMIC, GALAXY, SATURATED, etc.
-    pmSourceRoughClass (sources, config, psfClump);
+    psphotRoughClass (sources, config);
 
     // mark blended peaks PS_SOURCE_BLEND
     psphotBasicDeblend (sources, config, sky);
-    if (!strcasecmp (breakPt, "DEBLEND")) exit (0);
-
-    // source analysis is done in S/N order (brightest first)
-    sources = psArraySort (sources, psphotSortBySN);
-    psphotDumpMoments (config, sources);
-    if (!strcasecmp (breakPt, "CLASS")) exit (0);
 
     // use bright stellar objects to measure PSF
     psf = psphotChoosePSF (config, sources, sky);
-    if (!strcasecmp (breakPt, "PSFFIT")) exit (0);
 
+    // XXX change FITMODE to a string
+    int FITMODE = psMetadataLookupS32 (&status, config, "FIT_MODE");
     switch (FITMODE) {
       case 0:
@@ -101,5 +79,4 @@
 
     // write out data in appropriate format
-    psphotSamplePSFs (config, psf, imdata->image);
     psphotOutput (imdata, config, sources, psf, sky);
     psLogMsg ("psphot", 3, "wrote output: %f sec\n", psTimerMark ("psphot"));
