Index: trunk/psastro/src/psastro.c
===================================================================
--- trunk/psastro/src/psastro.c	(revision 6792)
+++ trunk/psastro/src/psastro.c	(revision 7014)
@@ -5,44 +5,60 @@
     psTimerStart ("complete");
 
-    psMetadata *header = NULL;
+    // model inits are needed in pmSourceIO
+    // XXX do we want to do the local model inits a la psphot?
+    pmModelGroupInit ();
 
     // load configuration information
     pmConfig *config = psastroArguments (&argc, argv);
 
-    // load input data (config and images (signal, noise, mask)
+    // load identify the data sources
     psastroParseCamera (config);
 
-    // perform the astrometric solution
-    psastroDataLoop (input, config);
+    // load the raw pixel data (from PSPHOT.SOURCES)
+    // select subset of stars for astrometry
+    psastroDataLoad (config);
 
-    // select astrometry stars from the psphot sources
-    // limit fit to bright stars only 
-    psastroSelectAstromStars (config);
+    // interpret the available initial astrometric information
+    // apply the initial guess
+    psastroAstromGuess (config);
 
     // load the reference stars overlapping the data stars
-    psastroLoadReference (config);
+    psArray *refs = psastroLoadReferences (config);
 
-    // fpa and subset point to the same astrometry terms
+    psastroChipAstrom (config, refs);
+
+    # if 0
+    // perform the desired astrometry analysis
     switch (mode) {
       case stack:
-	psastroStackAstrom (config);
+	psastroStackAstrom (config, refs);
+	break
+      case chip:
+	psastroChipAstrom (config, refs);
 	break
       case mosaic:
-	psastroMosaicAstrom (config);
-	break
-      case mosaic:
-	psastroMosaicAstrom (config);
+	psastroMosaicAstrom (config, refs);
 	break;
       default:
 	break;
     }
+    # endif
 
-    // perform the astrometric solution
+    // write out the results
     psastroDataSave (config);
 
-    psLogMsg ("psphot", 3, "complete psastro run: %f sec\n", psTimerMark ("complete"));
+    psLogMsg ("psastro", 3, "complete psastro run: %f sec\n", psTimerMark ("complete"));
 
+    psFree (refs);
     psFree (config);
-    psFree (fpa);
+
+    psTimerStop ();
+    psMemCheckCorruption (true);
+    pmModelGroupCleanup ();
+    psTimeFinalize ();
+    pmConceptsDone ();
+    pmConfigDone ();
+    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "psastro");
+    // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "psastro");
 
     exit (0);
