Index: trunk/ppStats/src/ppStats.c
===================================================================
--- trunk/ppStats/src/ppStats.c	(revision 7902)
+++ trunk/ppStats/src/ppStats.c	(revision 8337)
@@ -5,25 +5,22 @@
 #include "ppStats.h"
 
-int main(int argc, char *argv[])
+psMetadata *ppStats(psMetadata *out,    // Output metadata
+                    pmFPA *fpa,         // FPA for which to get statistics
+                    pmConfig *config    // Configuration
+    )
 {
+    // Get the options, open the files
+    ppStatsData *data = ppStatsSetupFromRecipe(NULL, config);
 
-    psLibInit(NULL);
-    psTimerStart(TIMERNAME);
-
-    // Parse the configuration and arguments
-    pmConfig *config = pmConfigRead(&argc, argv);
-
-    // Get the options, open the files
-    ppStatsData *data = ppStatsSetup(config);
+    if (data->fpa) {
+        psFree(data->fpa);
+    }
+    data->fpa = psMemIncrRefCounter(fpa);
 
     // Go through the FPA and do the hard work
-    ppStatsLoop(data, config);
+    out = ppStatsLoop(out, data, config);
 
     psFree(data);
-    psFree(config);
-    pmConceptsDone();
-    pmConfigDone();
-    psLibFinalize();
 
-    return EXIT_SUCCESS;
+    return out;
 }
