[boinc-app-seti] 01/01: Imported Upstream version 8.00~svn3352

Gianfranco Costamagna locutusofborg-guest at moszumanska.debian.org
Thu Jan 21 09:45:44 UTC 2016


This is an automated email from the git hooks/post-receive script.

locutusofborg-guest pushed a commit to annotated tag upstream/8.00_svn3352
in repository boinc-app-seti.

commit 071a70d0999a01817d9ea3afe1925d5ce6c1fead
Author: Gianfranco Costamagna <costamagnagianfranco at yahoo.it>
Date:   Thu Jan 21 10:01:31 2016 +0100

    Imported Upstream version 8.00~svn3352
---
 AUTHORS                                         |     5 +-
 Makefile.am                                     |    12 +-
 Makefile.incl                                   |     2 +-
 client/Makefile.am                              |     7 +-
 client/analyzeFuncs.cpp                         |   103 +-
 client/analyzePoT.cpp                           |    13 +-
 client/analyzeReport.cpp                        |    39 +-
 client/autocorr.cpp                             |    13 +-
 client/better_banner.jpg                        |   Bin 9068 -> 0 bytes
 client/gaussfit.cpp                             |    12 +
 client/i686_graphics_link                       |     1 +
 client/main.cpp                                 |    14 +-
 client/s_util.cpp                               |    60 +-
 client/s_util.h                                 |     2 +-
 client/sah_gfx.cpp                              |    31 +-
 client/sah_gfx_base.cpp                         |    49 +-
 client/sah_gfx_base.h                           |     1 +
 client/seti.cpp                                 |    39 +-
 client/seti.h                                   |     2 +-
 client/seti_header.cpp                          |    10 +-
 client/spike.cpp                                |    10 +
 client/test_workunits/init_data.xml             |    77 +
 client/test_workunits/reference_result_unit.sah |   307 +-
 client/test_workunits/reference_work_unit.sah   |    11 +-
 client/test_workunits/seti_logo                 |   Bin 0 -> 9714 bytes
 client/test_workunits/sponsor_bkg               |   Bin 0 -> 356520 bytes
 client/test_workunits/sponsor_logo              |   Bin 0 -> 13551 bytes
 client/vector/analyzeFuncs_avx.cpp              |     8 +-
 client/vector/analyzeFuncs_vector.cpp           |   173 +-
 client/vector/analyzeFuncs_vector.h             |     3 +
 client/vector/analyzeFuncs_vfp_aux.cpp          |    12 -
 client/vector/analyzeFuncs_x86_64.cpp           |    69 +-
 client/vector/fp_arm.h                          |    15 +-
 client/win-sah_config.h                         |    48 +-
 client/worker.cpp                               |     2 +-
 client/worker.h                                 |     1 -
 client/x86_64_graphics_link                     |     1 +
 configure.ac                                    |   132 +-
 db/schema_master.cpp                            | 29520 +++++++++++-----------
 db/schema_master.h                              |  2703 +-
 db/schema_master.sql                            |    53 +-
 db/schema_to_class.awk                          |    15 +-
 db/tools/analysis_configs.xml                   |    55 +-
 image_libs/Makefile                             |    13 +
 image_libs/Makefile.in                          |    13 +
 m4/ax_check_glut.m4                             |    22 +-
 m4/check_ssl.m4                                 |     5 +-
 m4/optimizations.m4                             |     4 +-
 m4/sah_check_boinc.m4                           |    11 +-
 m4/sah_grx.m4                                   |     2 +-
 ops/bin/run_gbt_splitter                        |   264 +
 ops/bin/run_mb_splitter                         |   276 +
 ops/bin/splitter_janitor                        |   276 +
 splitter_pfb/mb_read_blocks_dr2.cpp             |     7 +-
 splitter_pfb/mb_read_blocks_dr2.h               |     2 +-
 splitter_pfb/mb_read_blocks_guppi.cpp           |   561 +-
 splitter_pfb/mb_splitter.cpp                    |   174 +-
 splitter_pfb/mb_splitter.h                      |     6 +-
 splitter_pfb/mb_wufiles.cpp                     |    36 +-
 splitter_pfb/mb_wufiles.h                       |     6 +-
 validate/sah_result.cpp                         |     3 +-
 validate/sah_result.h                           |     1 +
 validate/sah_validate.cpp                       |    87 +-
 xcompile/xcompile.MinGW32_on_cygwin.sh          |   162 +
 64 files changed, 18820 insertions(+), 16741 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 1fafa15..17f7e60 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -15,11 +15,13 @@ Josef Segur
 Simon Zadra
 Jason Groothuis
 Raistmer
+Mateusz Szpakowski
 
 Authors of FFTW (reachable at fftw at fftw.org):
 Matteo Frigo <athena at fftw.org>
 Stevenj G. Johnson <stevenj at alum.mit.edu>
-Stefan Kral <skral at fftw.org> wrote genfft-k7/*.ml*
+Stefan Kral <skral at fftw.org> wrote genfft-k7/*.ml*, which was
+added in fftw-3.0 and removed in fftw-3.2.
 
 Authors of fft8g.[cpp,h]
 Takuya Ooura <ooura at kurims.kyoto-u.ac.jp>
@@ -29,3 +31,4 @@ Jeff Cobb <jeffc at ssl.berkeley.edu>
 Author of ASMLIB
 Agner Fog
 
+Background artwork by Tatiana Plakhova ( http://complexitygraphics.com/ )
diff --git a/Makefile.am b/Makefile.am
index a147252..6ab54d0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,7 @@ endif
 endif
 
 if ENABLE_SERVER
-  SERVER_SUBDIRS = splitter_pfb assimilator validate 
+  SERVER_SUBDIRS = splitter_pfb assimilator validate
 endif
 
 if USE_MY_IMAGELIBS
@@ -36,9 +36,11 @@ client-bin:
 	cd client && make client-bin client-bin-gz
 
 EXTRA_DIST =                                    \
-	db						\
-	tools						\
-        client/win_build                                   \
+	glut					\
+	image_libs				\
+	db					\
+	tools					\
+        client/win_build                                 \
         client/test_workunits                                   \
-    INSTALL    
+    INSTALL
 
diff --git a/Makefile.incl b/Makefile.incl
index 62cc811..89f28aa 100644
--- a/Makefile.incl
+++ b/Makefile.incl
@@ -28,7 +28,7 @@ PTHREAD_LIBS = @PTHREAD_LIBS@
 INFORMIXDIR = @INFORMIXDIR@
 INFORMIX_LIBS = @INFORMIX_LIBS@
 INFORMIX_CFLAGS = @INFORMIX_CFLAGS@
-APP_LIBS = @ASMLIB_LIBS@ @APP_LIBS@
+APP_LIBS = @ASMLIB_LIBS@ @APP_LIBS@ @CLIENT_EXTRA_LIBS@
 APP_LDFLAGS = @ASMLIB_LDFLAGS@ @APP_LDFLAGS@
 APP_CFLAGS = @ASMLIB_CFLAGS@ @APP_CFLAGS@
 GRAPHICS_CFLAGS = @GRAPHICS_CFLAGS@
diff --git a/client/Makefile.am b/client/Makefile.am
index f9c8236..233b632 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -9,6 +9,8 @@ CLIENT_C_FLAGS = $(APP_CFLAGS) $(CFLAGS) \
                 $(DEFS) \
 		-DTEXT_UI -DNDEBUG -DCLIENT \
 		-I$(top_srcdir)/db  \
+		-I$(top_srcdir)/client \
+		-I$(top_srcdir)/client/win_build \
 		$(BOINC_CFLAGS)  \
 		$(PTHREAD_CFLAGS)  \
 		$(ASMLIB_CFLAGS)
@@ -23,17 +25,16 @@ if ENABLE_GUI
      GUI_C_FLAGS = $(CLIENT_C_FLAGS) $(GRAPHICS_CFLAGS)
      GUI_LD_ADD = $(GRAPHICS_LIBS_RAW)
      CLIENT_LD_FLAGS += $(LDSTATIC)
-     CLIENT_LD_ADD += -L$(BOINCDIR)/api -L$(BOINCDIR)/lib $(BOINC_LIBS) $(AM_LIBS)
+     CLIENT_LD_ADD += -L$(BOINCDIR)/api -L$(BOINCDIR)/lib $(BOINC_LIBS) 
      SAH_GRX_SOURCES = sah_gfx_main.cpp 
 else
 #no graphics
      SAH_GRX_SOURCES =
-     CLIENT_LD_ADD += $(AM_LIBS)
      CLIENT_BIN = $(CLIENT_PROG) $(DEBUG_PROG) 
 endif
 
 if X86_64
-  CLIENT_C_FLAGS+=-msse2 -mfpmath=sse -DUSE_SSE -DUSE_SSE2 
+  CLIENT_C_FLAGS+= -march=opteron -mtune=generic -msse2 -DUSE_SSE -DUSE_SSE2 
 endif
 
 all: client-bin
diff --git a/client/analyzeFuncs.cpp b/client/analyzeFuncs.cpp
index 552dad3..abd9179 100644
--- a/client/analyzeFuncs.cpp
+++ b/client/analyzeFuncs.cpp
@@ -54,6 +54,7 @@ const char *SAH_PACKAGE_STRING=CUSTOM_STRING;
 #include <iostream>
 #include <cstdlib>
 #include <cmath>
+#include <climits>
 #ifdef HAVE_MEMORY_H
 #include <memory.h>
 #endif
@@ -104,7 +105,7 @@ const char *SAH_PACKAGE_STRING=CUSTOM_STRING;
 #include <ipp.h>
 #elif defined(USE_FFTWF)
 #pragma message ("----FFTW----")
-#include "fftw3.h"
+#include <fftw3.h>
 #else
 #pragma message ("----ooura----")
 #include "fft8g.h"
@@ -173,6 +174,10 @@ void CalcTrigArray (int len, int ChirpRateInd);
 int icfft;  // for debug
 #endif
 
+#ifdef USE_FFTWF
+    fftwf_plan transpose_plans[MAX_NUM_FFTS];
+#endif
+
 int seti_analyze (ANALYSIS_STATE& state) {
     sah_complex* DataIn = state.savedWUData;
     int NumDataPoints = state.npoints;
@@ -299,7 +304,6 @@ int seti_analyze (ANALYSIS_STATE& state) {
 #ifdef USE_IPP
             int order = 0;
             for (int tmp = FftLen; !(tmp & 1); order++) tmp >>= 1;
-            if (ippsFFTInitAlloc_C_32fc(&FftSpec[FftNum], order,
                                         IPP_FFT_NODIV_BY_ANY, ippAlgHintFast)) {
                 SETIERROR (MALLOC_FAILED, "ippsFFTInitAlloc failed");
             }
@@ -311,8 +315,8 @@ int seti_analyze (ANALYSIS_STATE& state) {
 #else
 
 
-            WorkData = (sah_complex *)malloc_a(FftLen * sizeof(sah_complex),MEM_ALIGN);
-            sah_complex *scratch=(sah_complex *)malloc_a(FftLen*sizeof(sah_complex),MEM_ALIGN);
+            WorkData = (sah_complex *)malloc_a(swi.nsamples * sizeof(float),MEM_ALIGN);
+            sah_complex *scratch=(sah_complex *)malloc_a(swi.nsamples*sizeof(float),MEM_ALIGN);
             if ((WorkData == NULL) || (scratch==NULL)) {
                 SETIERROR(MALLOC_FAILED, "WorkData == NULL || scratch == NULL");
             }
@@ -325,9 +329,17 @@ int seti_analyze (ANALYSIS_STATE& state) {
 #ifdef USE_MANUAL_CALLSTACK
             call_stack.exit();
 #endif
-#endif
+            if (use_transposed_pot) {
+                fftwf_iodim dims[2];
+                dims[0].n  = swi.nsamples/FftLen;
+                dims[0].is = FftLen;
+                dims[0].os = 1;
+                dims[1].n  = FftLen;
+                dims[1].is = 1;
+                dims[1].os = swi.nsamples/FftLen;
+                transpose_plans[FftNum] = fftwf_plan_guru_r2r(0, NULL, 2, dims, (float *)WorkData, (float *)scratch, NULL, FFTW_MEASURE_OR_ESTIMATE);
+            }
             FftNum++;
-#ifdef USE_FFTWF
             free_a(scratch);
             free_a(WorkData);
 #endif /* USE_FFTWF */
@@ -778,6 +790,7 @@ int seti_analyze (ANALYSIS_STATE& state) {
             SETIERROR(WRITE_FAILED,"from outfile.printf (best triplet) in seti_analyze()");
         }
     }
+    retval=outfile.printf("<setiathome_version>"PACKAGE_VERSION"</setiathome_version>\n");
 
 #ifdef BOINC_APP_GRAPHICS
     if (sah_graphics) strcpy(sah_graphics->status, "Work unit done");
@@ -1463,3 +1476,81 @@ int v_Transpose8(int x, int y, float * __restrict in, float * __restrict out) {
     return 0;
 }
 
+#if !defined(HAVE_INT32_T) 
+#if defined(HAVE__INT32)
+typedef _int32 int32_t;
+#elif (SIZEOF_LONG == 4)
+typedef long int32_t;
+#elif (SIZEOF_INT == 4)
+typedef int int32_t;
+#elif (SIZEOF_SHORT == 4)
+typedef short int32_t;
+#else 
+// not much else I can do.
+typedef int int32_t;
+#endif
+#endif
+
+#if !defined(HAVE_UINT32_T) 
+#if defined(HAVE__UINT32)
+typedef _uint32 uint32_t;
+#elif (SIZEOF_LONG == 4)
+typedef unsigned long uint32_t;
+#elif (SIZEOF_INT == 4)
+typedef unsigned int uint32_t;
+#elif (SIZEOF_SHORT == 4)
+typedef unsigned short uint32_t;
+#else 
+// not much else I can do.
+typedef unsigned int uint32_t;
+#endif
+#endif
+
+
+inline uint32_t ones32(register uint32_t x) {
+#ifdef HAVE___BUILTIN_POPCOUNT
+        return __builtin_popcount(x);
+#else
+        /* 32-bit recursive reduction using SWAR...
+	   but first step is mapping 2-bit values
+	   into sum of 2 1-bit values in sneaky way
+	*/
+        x -= ((x >> 1) & 0x55555555);
+        x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
+        x = (((x >> 4) + x) & 0x0f0f0f0f);
+        x += (x >> 8);
+        x += (x >> 16);
+        return(x & 0x0000003f);
+#endif
+}
+
+inline uint32_t ilog2(int32_t n) {
+  register int32_t rv=-1;
+  if (n) {
+#if defined(HAVE___BUILTIN_CLZ)
+    rv=(CHAR_BIT*sizeof(n))-__builtin_clz(n)-1;
+#else
+    n |= (n >> 1);
+    n |= (n >> 2);
+    n |= (n >> 4);
+    n |= (n >> 8);
+    n |= (n >> 16); 
+    rv=(ones32(n >> 1));
+#endif
+  }
+return rv;
+}
+
+int fftwf_transpose(int x, int y, float *in, float *out) {
+    int i;
+#ifdef USE_MANUAL_CALLSTACK
+    call_stack.enter("fftwf_transpose");
+#endif
+    i=ilog2(x)-3;
+    fftwf_execute_r2r(transpose_plans[i], in, out);
+#ifdef USE_MANUAL_CALLSTACK
+    call_stack.exit();
+#endif
+    return 0;
+}
+
diff --git a/client/analyzePoT.cpp b/client/analyzePoT.cpp
index 1358121..d16b2dd 100644
--- a/client/analyzePoT.cpp
+++ b/client/analyzePoT.cpp
@@ -100,12 +100,12 @@ int analyze_pot(
                               ProgressPerPulsePoT = 0.0;  // for local progress display
 
     bool SkipGauss   = false,
-                       SkipPulse   = false,
-                                     SkipTriplet = false,
-                                                   TOffsetOK   = true;
+         SkipPulse   = false,
+         SkipTriplet = false,
+         TOffsetOK   = true;
 
     static float  *GaussPoT = NULL,
-                              *PulsePoT = NULL;
+                  *PulsePoT = NULL;
 
 #ifdef DUMP_POWER_SPECTRA
 
@@ -582,6 +582,7 @@ void ComputePoTInfo(int num_cfft, int NumDataPoints) {
     // amount of time it takes to cover 1/2 the half-power-beamwidth of the
     // serendip feed.  This is also a constant - BEAM_WIDTH - in units of
     // degrees.  We scan BEAM_WIDTH degrees at a given, but variable, slew rate.
+    //
 
 
     volatile double DegPerPotBin;    // slew rate in degrees per PoT bin
@@ -620,6 +621,8 @@ void ComputePoTInfo(int num_cfft, int NumDataPoints) {
     ftmp               = (float)(swi.nsamples / swi.subband_sample_rate);
     PoTInfo.WUDuration = ftmp;
 
+    // 11/2/15 - EK increased accuracy of conversion from HPBW to gaussian sigma
+    //
     // Here we calculate slew rate and slew related values.
     // If there is no telescope movement, slew related values remain
     // in their initialized state (zero).
@@ -629,7 +632,7 @@ void ComputePoTInfo(int num_cfft, int NumDataPoints) {
         ftmp                        = (float)(PoTInfo.SlewRate / swi.beam_width);
         PoTInfo.BeamRate            = ftmp;
         DegPerPotBin                = swi.angle_range / swi.analysis_cfg.gauss_pot_length;
-        ftmp                        = (float)((swi.beam_width/2.0f) / DegPerPotBin);
+        ftmp                        = (float)((swi.beam_width/2.35482f) / DegPerPotBin);
         PoTInfo.GaussSigma          = ftmp;
         PoTInfo.GaussSigmaSq        = PoTInfo.GaussSigma * PoTInfo.GaussSigma;
         PoTInfo.GaussTOffsetStart   = static_cast<int>(floor(swi.analysis_cfg.pot_t_offset * PoTInfo.GaussSigma+0.5));
diff --git a/client/analyzeReport.cpp b/client/analyzeReport.cpp
index fada3e0..5d60e0f 100644
--- a/client/analyzeReport.cpp
+++ b/client/analyzeReport.cpp
@@ -175,7 +175,7 @@ int result_spike(SPIKE_INFO &si) {
 
   //R: & JWS: sanity check for found result
   if(si.s.peak_power > si.s.fft_len){
-    boinc_temporary_exit(5*60,"Impossible Spike, retrying from checkpoint.");
+    boinc_temporary_exit(5*60,"Impossible Spike, retrying from checkpoint.",true);
   }
 
 
@@ -231,7 +231,7 @@ int result_gaussian(GAUSS_INFO &gi) {
 
   //R: & JWS: sanity check for found result
   if(gi.g.peak_power > swi.analysis_cfg.gauss_pot_length){
-    boinc_temporary_exit(5*60,"Improbable Gaussian, retrying from checkpoint.");}
+    boinc_temporary_exit(5*60,"Improbable Gaussian, retrying from checkpoint.",true);}
 
 
   int retval=0;
@@ -282,7 +282,7 @@ BOINCASSERT(_CrtCheckMemory());
 
   //JWS: sanity check for found result.
   if(Power > (float)pot_len){
-    boinc_temporary_exit(5*60,"Impossible Triplet, retrying from checkpoint.");
+    boinc_temporary_exit(5*60,"Impossible Triplet, retrying from checkpoint.",true);
   }
 
   if (!inv) inv = (int*)calloc_a(swi.analysis_cfg.triplet_pot_length, sizeof(int), MEM_ALIGN);
@@ -331,7 +331,7 @@ BOINCASSERT(_CrtCheckMemory());
       }
     }
   } else {
-    memset(inv, -1, sizeof(inv));
+    memset(inv, -1, swi.analysis_cfg.triplet_pot_length*sizeof(int));
     for (i=0;i<swi.analysis_cfg.triplet_pot_length;i++) {
       j = (i*pot_len)/swi.analysis_cfg.triplet_pot_length;
       if (inv[j] < 0) inv[j] = i;
@@ -359,13 +359,23 @@ BOINCASSERT(_CrtCheckMemory());
 
   // best thus far ?
   if (ti.score>best_triplet->score) {
-    *best_triplet=ti;
+	if(verbose>=2){
+    	fprintf(stderr,"Best triplet updated:");
+    	fprintf(stderr,"score=%.4g; power=%.4g; freq_bin=%.4g; icfft=%d\n",  
+	    	ti.score,ti.t.peak_power,ti.freq_bin,analysis_state.icfft);
+    }
+	*best_triplet=ti;
   }
 
 
   if (write_triplet) {
-
-    retval = outfile.printf("%s", ti.t.print_xml(0,0,1).c_str());
+	if(verbose>=1){
+    	int fft=(ti.t.fft_len>1024)?(ti.t.fft_len/1024):(ti.t.fft_len);
+    	char symbol=(ti.t.fft_len>1024)?('k'):(' ');
+    	fprintf(stderr,"Triplet: peak=%.7g, time=%.4g, period=%.4g, d_freq=%.12g, chirp=%.5g, fft_len=%d%c\n",
+	    	ti.t.peak_power,(ti.t.time-swi.time_recorded)*86400,ti.t.period,ti.t.detection_freq,ti.t.chirp_rate,fft,symbol);
+    }
+	retval = outfile.printf("%s", ti.t.print_xml(0,0,1).c_str());
 
     if (retval < 0) {
       SETIERROR(WRITE_FAILED,"in ReportTripletEvent");
@@ -409,7 +419,7 @@ BOINCASSERT(_CrtCheckMemory());
   //JWS: sanity check for found result. The limit would be 4/3 * period,
   // but discrete math and short PoTs can exceed that slightly.
   if(PulsePower > 1.4 * period){
-    boinc_temporary_exit(5*60,"Impossible Pulse, retrying from checkpoint.");
+    boinc_temporary_exit(5*60,"Impossible Pulse, retrying from checkpoint.",true);
   }
 
   // pulse info
@@ -483,6 +493,10 @@ BOINCASSERT(_CrtCheckMemory());
   // best thus far ?
   if (pi.score>best_pulse->score) {
     *best_pulse=pi;
+	if(verbose>=2){
+      fprintf(stderr,"Best pulse updated: score=%.4g,power=%.5g,fftlen=%d,freq_bin=%d,time_bin=%d,icfft=%d\n",
+	    pi.score,pi.p.peak_power,pi.p.fft_len,pi.freq_bin,pi.time_bin,analysis_state.icfft);
+  	}
   }
 
   if (write_pulse) {
@@ -490,8 +504,13 @@ BOINCASSERT(_CrtCheckMemory());
     //for (i=0;i<len_prof;i++) {
 //	sprintf(&pi.p.pot[i], "%02x",(int)((folded_pot[i]-MinPower)*norm));
  //   }
-
-    retval = outfile.printf("%s", pi.p.print_xml(0,0,1).c_str());
+	if(verbose>=1){
+    	int fft=(pi.p.fft_len>1024)?(pi.p.fft_len/1024):(pi.p.fft_len);
+    	char symbol=(pi.p.fft_len>1024)?('k'):(' ');
+    	fprintf(stderr,"Pulse: peak=%.7g, time=%.4g, period=%.4g, d_freq=%.12g, score=%.4g, chirp=%.5g, fft_len=%d%c\n",
+	    	pi.p.peak_power,(pi.p.time-swi.time_recorded)*86400,pi.p.period,pi.p.detection_freq,pi.score,pi.p.chirp_rate,fft,symbol);
+    }
+	retval = outfile.printf("%s", pi.p.print_xml(0,0,1).c_str());
 
     if (retval >= 0) {
       outfile.printf("\n");
diff --git a/client/autocorr.cpp b/client/autocorr.cpp
index d5bbb0b..6a0d7c1 100644
--- a/client/autocorr.cpp
+++ b/client/autocorr.cpp
@@ -118,7 +118,7 @@ int FindAutoCorrelation(
 
     //JWS: Sanity check, delayed peaks cannot be higher than the zero delay power.
     if (temp > AutoCorrelation[0]) {
-      boinc_temporary_exit(5*60,"Impossible Autocorr power, retrying from checkpoint.");
+      boinc_temporary_exit(5*60,"Impossible Autocorr power, retrying from checkpoint.",true);
     }
 
     //  autocorr info
@@ -142,6 +142,11 @@ int FindAutoCorrelation(
     // if best_autocorr.s.fft_len == 0, there is not yet a first autocorr
     if (ai.score > best_autocorr->score || best_autocorr->a.fft_len == 0) {
       *best_autocorr 			= ai;
+	if(verbose>=2){
+      fprintf(stderr,"Best autocorr updated:");
+      fprintf(stderr,"score=%.4g, peak_power=%.4g, bin=%d, fft_ind=%d, icfft=%d\n",
+	      ai.score,ai.a.peak_power,ai.bin,ai.fft_ind,analysis_state.icfft);
+	}
 #ifdef BOINC_APP_GRAPHICS
       if (!nographics()) sah_graphics->ai.copy(&ai);
 #endif
@@ -150,6 +155,12 @@ int FindAutoCorrelation(
     // Report a signal if it excceeds threshold.
     if (ai.a.peak_power > (swi.analysis_cfg.autocorr_thresh)) {
       retval = result_autocorr(ai);
+	  if(verbose>=1){
+      	int fft=(ai.a.fft_len>1024)?(ai.a.fft_len/1024):(ai.a.fft_len);
+      	char symbol=(ai.a.fft_len>1024)?('k'):(' ');
+      	fprintf(stderr,"Autocorr: peak=%.7g, time=%.4g, delay=%.5g, d_freq=%.12g, chirp=%.5g, fft_len=%d%c\n",
+	      ai.a.peak_power,(ai.a.time-swi.time_recorded)*86400,ai.a.delay,ai.a.detection_freq,ai.a.chirp_rate,fft,symbol);
+	  }
       if (retval) SETIERROR(retval,"from result_autocorr()");
     }
   }
diff --git a/client/better_banner.jpg b/client/better_banner.jpg
deleted file mode 100644
index a293b80..0000000
Binary files a/client/better_banner.jpg and /dev/null differ
diff --git a/client/gaussfit.cpp b/client/gaussfit.cpp
index 27f0919..8139a59 100644
--- a/client/gaussfit.cpp
+++ b/client/gaussfit.cpp
@@ -316,6 +316,11 @@ int ChooseGaussEvent(
   // in the best Gaussian display. 
   if (gi.score > best_gauss->score && chisqOK) {
     *best_gauss = gi;
+	if(verbose>=2){
+    	fprintf(stderr,"Best gaussian updated: score=%.7g, fft_len=%d, PoT=%d, Offset=%d,\n\tPeak=%.7g, TrueMean=%.7g,ChiSq=%.7g,null_hyp=%.7g,PoTMaxPower=%.7g,icfft=%d\n",
+      		gi.score,ChirpFftPairs[analysis_state.icfft].FftLen,bin,ifft,
+      	PeakPower,TrueMean,ChiSq,null_ChiSq,PoTMaxPower,analysis_state.icfft);
+  	}
   }
   // Update gdata gauss info regardless of whether it is the
   // best thus far or even passes the final threshold.  If
@@ -329,6 +334,13 @@ int ChooseGaussEvent(
   // Final reporting.
   if (report) {
       int retval=result_gaussian(gi);
+	  if(verbose>=1){
+      	int fft=(gi.g.fft_len>1024)?(gi.g.fft_len/1024):(gi.g.fft_len);
+      	char symbol=(gi.g.fft_len>1024)?('k'):(' ');
+      	fprintf(stderr,"Gaussian: peak=%.7g, mean=%.7g, ChiSq=%.7g, time=%.4g, d_freq=%.12g,\n\tscore=%.7g, null_hyp=%.7g, chirp=%.5g, fft_len=%d%c\n",
+        	gi.g.peak_power,gi.g.mean_power,gi.g.chisqr,(gi.g.time-swi.time_recorded)*86400,gi.g.detection_freq,gi.score,
+        	gi.g.null_chisqr,gi.g.chirp_rate,fft,symbol);
+	  }
 #ifdef USE_MANUAL_CALLSTACK
       call_stack.exit();
 #endif 
diff --git a/client/i686_graphics_link b/client/i686_graphics_link
new file mode 100644
index 0000000..59afae2
--- /dev/null
+++ b/client/i686_graphics_link
@@ -0,0 +1 @@
+ g++ -m32 -O3 -I/usr/local/include -static-libgcc -g -Wall -I/usr/local/include -I/usr/include -I/usr/include/openssl -DHAVE_CONFIG_H -DTEXT_UI -DNDEBUG -DCLIENT -I../db -I../client -I../client/win_build -I/home/korpela/build/i686-linux/boinc -I/home/korpela/build/i686-linux/boinc/api -I/home/korpela/build/i686-linux/boinc/lib -I/home/korpela/build/i686-linux/boinc/sched -I/home/korpela/build/i686-linux/boinc/db -I/home/korpela/build/i686-linux/boinc/clientgui/mac -pthread -msse2 -mfpmat [...]
diff --git a/client/main.cpp b/client/main.cpp
index 80a37ac..cfec958 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -33,6 +33,7 @@
 // Usage: client [options]
 // -version  show version info
 // -verbose  print running status
+// -v N level N of verbosity (N==2 to print best signals formation, N==0 to disable signals output)
 // -standalone
 
 
@@ -107,6 +108,7 @@ void usage() {
 #endif
     " -version  show version info\n"
     " -verbose  print running status\n"
+	" -v N level N of verbosity (N==2 to print best signals formation, N==0 to disable signals output)\n"
   );
 }
 
@@ -213,8 +215,12 @@ int main(int argc, char** argv) {
 #endif /* USE_MANUAL_CALLSTACK */
       exit(0);
     } else if (!strncmp(p,"verb",4)) {
-      verbose = true;
-    } else if (!strncmp(p, "st", 2)) {
+      verbose = 2;
+	} else if (!strncmp(p,"v",1)){
+			if(++i<argc)verbose=atoi(argv[i]);
+			else verbose=2;
+	}
+	else if (!strncmp(p, "st", 2)) {
         standalone = true;
 #ifdef BOINC_APP_GRAPHICS
         nographics_flag = true;
@@ -237,7 +243,7 @@ int main(int argc, char** argv) {
     }
   }
 #ifdef USE_MANUAL_CALLSTACK
-  if (verbose) call_stack.set_verbose(true);
+  if (verbose>1) call_stack.set_verbose(true);
 #endif /* USE_MANUAL_CALLSTACK */
 
   try {
@@ -257,7 +263,7 @@ int main(int argc, char** argv) {
       SETIERROR(retval, "from boinc_init_diagnostics()");
     }
 
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(__ppc__)
     setMacIcon(argv[0], MacAppIconData, sizeof(MacAppIconData));
 #ifdef __i386__
     rlimit rlp;
diff --git a/client/s_util.cpp b/client/s_util.cpp
index c874e46..640e4bb 100644
--- a/client/s_util.cpp
+++ b/client/s_util.cpp
@@ -203,22 +203,60 @@ int read_bin_data(unsigned char* bin, int nbytes, FILE* f) {
 
 // see the doc on binary data representation
 
-void bits_to_floats(unsigned char* raw, sah_complex* data, int nsamples) {
+void bits_to_floats(unsigned char* raw, sah_complex* data, int nsamples, int bits_per_sample) {
 #ifdef USE_MANUAL_CALLSTACK
   call_stack.enter("bits_to_floats");
 #endif 
   int i, j, k=0;
   unsigned char c;
-
-  for (i=0; i<nsamples/4; i++) {
-    j = (i&1) ? i-1 : i+1;
-    c = raw[j];
-    for (j=0; j<4; j++) {
-      data[k][0] = (float)((c&2)?1:-1);
-      data[k][1] = (float)((c&1)?1:-1);
-      k++;
-      c >>= 2;
-    }
+  const float v2[2]={-1.0,1.0};
+  const float v4[4]={-3.3358750,-1.0,1.0,3.3358750};
+  switch (bits_per_sample) {
+    case 2:
+        for (i=0; i<nsamples/4; i++) {
+            j = (i&1) ? i-1 : i+1;
+            c = raw[j];
+            for (j=0; j<4; j++) {
+                data[k][0] = v2[(c>>1)&1];
+                data[k][1] = v2[(c&1)];
+                k++;
+                c >>= 2;
+            }
+        }
+        break;
+    case 4:
+        for (i=0; i<nsamples/2; i++) {
+            j = (i&1) ? i-1 : i+1;
+            c = raw[j];
+            for (j=0; j<2; j++) {
+                data[k][0] = v4[(c>>2)&3];
+                data[k][1] = v4[c&3];
+                k++;
+                c >>= 4;
+            }
+        }
+        break;
+    case 8:
+        for (i=0; i<nsamples; i++) {
+            j = (i&1) ? i-1 : i+1;
+            c = raw[j];
+            data[k][0] = static_cast<float>((c>>4)&15)-7.5f;
+            data[k][1] = static_cast<float>(c&15)-7.5f;
+            k++;
+        }
+        break;
+    case 16:
+        for (i=0; i<nsamples*2; i+=2) {
+            signed char sc = raw[i+1];
+            data[k][0] = static_cast<float>(sc);
+            sc = raw[i];
+            data[k][1] = static_cast<float>(sc);
+            k++;
+        }
+        break;
+    default: 
+        fprintf(stderr,"Unsupported bit depth (%d)\n",bits_per_sample);
+        throw BAD_DECODE;
   }
 #ifdef USE_MANUAL_CALLSTACK
   call_stack.exit();
diff --git a/client/s_util.h b/client/s_util.h
index 5e01665..c21ffae 100644
--- a/client/s_util.h
+++ b/client/s_util.h
@@ -145,7 +145,7 @@ extern void strip_cr(char*p );
 extern void encode(unsigned char* bin, int nbytes, FILE* f);
 extern int decode(unsigned char* bin, int nbytes, FILE* f);
 extern int read_bin_data(unsigned char* bin, int nbytes, FILE* f);
-extern void bits_to_floats(unsigned char* raw, sah_complex *data, int nsamples);
+extern void bits_to_floats(unsigned char* raw, sah_complex *data, int nsamples, int bits_per_sample=2);
 extern int float_to_uchar(
     float float_element[], unsigned char char_element[],
     long num_elements, float scale_factor
diff --git a/client/sah_gfx.cpp b/client/sah_gfx.cpp
index 8a48d79..93b0fa1 100644
--- a/client/sah_gfx.cpp
+++ b/client/sah_gfx.cpp
@@ -75,7 +75,17 @@
 #if !defined(__MINGW32__) && !defined(_MSC_VER)
       #include <gl/glaux.h>        // Header File For The Glaux Library
 #endif
+#if defined(HAVE_GLUT_H)
 #include <glut.h>
+#elif defined(HAVE_GL_GLUT_H)
+#include <gl/glut.h>
+#elif defined(HAVE_FREEGLUT_H)
+#include <freeglut.h>
+#elif defined(HAVE_GL_FREEGLUT_H)
+#include <gl/freeglut.h>
+#else
+#include <glut.h>
+#endif
 #endif
 
 #ifndef _WIN32
@@ -294,15 +304,23 @@ void SAH_GRAPHICS::render_pillars(double time_of_day, double dt) {
     float tripletData[TRIPLET_POT_LEN];
     float gaussFunc[GAUSS_POT_LEN];
     char buf[512],time_buf[256];
-    const char *TitleText="SETI at home 7";
+    const char *TitleText="SETI at home 8";
 
 
     int s4_id=3;
 
     if (gdata && gdata->ready) {
         s4_id=gdata->wu.s4_id;
-        if (s4_id > 2) {
-            TitleText="SETI at home Version 7";
+        if ((s4_id > 2) && (s4_id < 17)) {
+            TitleText="SETI at home Version 8";
+        } else if (s4_id >= 17) {
+            time_t t=time(0);
+            struct tm *tm=localtime(&t);
+            if (tm->tm_year >= 116) {
+              TitleText="SETI at home/Breakthrough!";
+            } else {
+              TitleText="SETI at home Version 8";
+            }
         }
     }
 
@@ -800,9 +818,14 @@ void SAH_GRAPHICS::render(int xs, int ys, double time_of_day) {
     if (!sah_shmem) {
         sah_shmem = (SAH_SHMEM*)boinc_graphics_get_shmem("setiathome");
         gdata = &(sah_shmem->gdata);
+        setup_given_prefs();
+    }
+    if (!gdata) {
+        fprintf(stderr, "shared memory segment missing\n");
+        exit(1);
     }
     gdata->countdown = 5;
-
+    
     if (last_time != 0) {
         dt = time_of_day - last_time;
     }
diff --git a/client/sah_gfx_base.cpp b/client/sah_gfx_base.cpp
index bf920d1..a5b8728 100644
--- a/client/sah_gfx_base.cpp
+++ b/client/sah_gfx_base.cpp
@@ -72,7 +72,9 @@
 
 #define SETI_LOGO_FILENAME "seti_logo"
 #define USER_LOGO_FILENAME "user_logo"
+#define SPONSOR_LOGO_FILENAME "sponsor_logo"
 #define BACKGROUND_FILENAME "background"
+#define SPONSOR_BKG_FILENAME "sponsor_bkg"
 
 // maximum resolutions for power graph
 #define MAX_GRAPH_RES_X 200
@@ -122,16 +124,16 @@ void GRAPHICS_PREFS::defaults() {
     graph_style = GRAPH_STYLE_RECTANGLES;
     max_fps = 20;
     max_cpu = 30;
-    grow_time = 3;
-    hold_time = 2;
+    grow_time = 10;
+    hold_time = 10;
     graph_alpha = 0.7;
 
-    pitch_period = 10;
+    pitch_period = 100;
     pitch_range = 20;
-    roll_period = 30;
+    roll_period = 300;
     roll_range = 30;
 	starfield_size = 2000;
-	starfield_speed = 400.0f;
+	starfield_speed = 40.0f;
     
     start_hue = 0.2;
     hue_change = 0.7;
@@ -237,7 +239,7 @@ static void initlights() {
 
 void SAH_GRAPHICS_BASE::render_logos() {    
 	float pos[3] = {.03, .03, 0};
-	float size[3] = {.5, .14, 0};
+	float size[3] = {.27, .3, 0};
     bool any = seti_logo_texture.present || user_logo_texture.present;
 
     if (any) {
@@ -320,6 +322,9 @@ void SAH_GRAPHICS_BASE::graphics_thread_init() {
     glClearColor(0.0f, 0.0f, 0.0f, 0.0f);		// Black Background
     glClearDepth(1.0f);					// Depth Buffer Setup
     glEnable(GL_DEPTH_TEST);				// Enables Depth Testing
+    glEnable(GL_LINE_SMOOTH);
+    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 
+    glEnable(GL_BLEND);
     glDepthFunc(GL_LEQUAL);				// The Type Of Depth Testing To Do
     glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
     initlights();
@@ -341,7 +346,7 @@ void SAH_GRAPHICS_BASE::resize(int w, int h) {
 }
 
 void SAH_GRAPHICS_BASE::setup_given_prefs() {
-	char filename[256];
+    char filename[256],bkg_filename[256];
 
     boinc_max_fps = max_fps;
     boinc_max_gfx_cpu_frac = max_cpu/100.;
@@ -351,7 +356,7 @@ void SAH_GRAPHICS_BASE::setup_given_prefs() {
     seti_logo_texture.present = false;
     user_logo_texture.present = false;
     background_texture.present = false;
-
+       
     double fsize=0;
     boinc_resolve_filename(SETI_LOGO_FILENAME, filename, sizeof(filename));
     if (!file_size(filename,fsize) && (fsize>4096)) {
@@ -360,8 +365,30 @@ void SAH_GRAPHICS_BASE::setup_given_prefs() {
         fprintf(stderr,"Warning: unable to load JPEG file. File size=%d\n",(int)fsize);
 	    seti_logo_texture.present=false;
     }
-    boinc_resolve_filename(USER_LOGO_FILENAME, filename, sizeof(filename));
+    if (gdata) {
+      int s4_id=gdata->wu.s4_id;
+      if (s4_id >= 17) {
+          time_t t=time(0);
+          struct tm *tm=localtime(&t);
+          if (tm->tm_year >= 116) {
+             boinc_resolve_filename(SPONSOR_LOGO_FILENAME, filename, sizeof(filename));
+             boinc_resolve_filename(SPONSOR_BKG_FILENAME, bkg_filename, sizeof(bkg_filename));
+             if (!boinc_file_exists(filename))
+                boinc_resolve_filename(USER_LOGO_FILENAME, filename, sizeof(filename));
+             if (!boinc_file_exists(bkg_filename))
+                boinc_resolve_filename(BACKGROUND_FILENAME, bkg_filename, sizeof(bkg_filename));
+          } else {  
+             boinc_resolve_filename(USER_LOGO_FILENAME, filename, sizeof(filename));
+             boinc_resolve_filename(BACKGROUND_FILENAME, bkg_filename, sizeof(bkg_filename));
+          }
+        } else {
+          boinc_resolve_filename(USER_LOGO_FILENAME, filename, sizeof(filename));
+          boinc_resolve_filename(BACKGROUND_FILENAME, bkg_filename, sizeof(filename));
+      }
+    } else {
+      boinc_resolve_filename(USER_LOGO_FILENAME, filename, sizeof(filename));
+      boinc_resolve_filename(BACKGROUND_FILENAME, bkg_filename, sizeof(filename));
+    }
     user_logo_texture.load_image_file(filename);
-    boinc_resolve_filename(BACKGROUND_FILENAME, filename, sizeof(filename));
-    background_texture.load_image_file(filename);
+    background_texture.load_image_file(bkg_filename);
 }
diff --git a/client/sah_gfx_base.h b/client/sah_gfx_base.h
index 487dd36..009c700 100644
--- a/client/sah_gfx_base.h
+++ b/client/sah_gfx_base.h
@@ -1,3 +1,4 @@
+
 // Copyright 2003 Regents of the University of California
 
 // SETI_BOINC is free software; you can redistribute it and/or modify it under
diff --git a/client/seti.cpp b/client/seti.cpp
index c4a6861..c566fea 100644
--- a/client/seti.cpp
+++ b/client/seti.cpp
@@ -1073,7 +1073,7 @@ int seti_parse_data(FILE* f, ANALYSIS_STATE& state) {
           if (bin_data) free_a(bin_data);
           SETIERROR(i,"in seti_parse_data()");
       }
-      bits_to_floats((unsigned char *)bin_data, data, nsamples);
+      bits_to_floats((unsigned char *)bin_data, data, nsamples,swi.bits_per_sample);
       memcpy(bin_data,data,nsamples*sizeof(sah_complex));
       state.savedWUData = bin_data;
       break;
@@ -1117,6 +1117,43 @@ void final_report() {
 #ifdef USE_MANUAL_CALLSTACK
   call_stack.enter("final_report()");
 #endif 
+  if(verbose>0){
+	{
+	int fft=(best_spike->s.fft_len>1024)?(best_spike->s.fft_len/1024):(best_spike->s.fft_len);
+	char symbol=(best_spike->s.fft_len>1024)?('k'):(' ');
+	fprintf(stderr,"\nBest spike: peak=%.7g, time=%.4g, d_freq=%.12g, chirp=%.5g, fft_len=%d%c\n",
+		best_spike->s.peak_power,(best_spike->s.time-swi.time_recorded)*86400,best_spike->s.detection_freq,best_spike->s.chirp_rate,fft,symbol);
+  }
+  if(swi.analysis_cfg.autocorr_fftlen){
+	int fft=(best_autocorr->a.fft_len>1024)?(best_autocorr->a.fft_len/1024):(best_autocorr->a.fft_len);
+	char symbol=(best_autocorr->a.fft_len>1024)?('k'):(' ');
+	fprintf(stderr,"Best autocorr: peak=%.7g, time=%.4g, delay=%.5g, d_freq=%.12g, chirp=%.5g, fft_len=%d%c\n",
+		best_autocorr->a.peak_power,(best_autocorr->a.time-swi.time_recorded)*86400,best_autocorr->a.delay,best_autocorr->a.detection_freq,
+		best_autocorr->a.chirp_rate,fft,symbol);
+  }
+  {
+	int fft=(best_gauss->g.fft_len>1024)?(best_gauss->g.fft_len/1024):(best_gauss->g.fft_len);
+	char symbol=(best_gauss->g.fft_len>1024)?('k'):(' ');
+		fprintf(stderr,"Best gaussian: peak=%.7g, mean=%.7g, ChiSq=%.7g, time=%.4g, d_freq=%.12g,\n\tscore=%.7g, null_hyp=%.7g, chirp=%.5g, fft_len=%d%c\n",
+			best_gauss->g.peak_power,best_gauss->g.mean_power,best_gauss->g.chisqr,(best_gauss->g.time-swi.time_recorded)*86400,best_gauss->g.detection_freq,
+			best_gauss->score,best_gauss->g.null_chisqr,best_gauss->g.chirp_rate,fft,symbol);
+  }
+  {
+	int fft=(best_pulse->p.fft_len>1024)?(best_pulse->p.fft_len/1024):(best_pulse->p.fft_len);
+	char symbol=(best_pulse->p.fft_len>1024)?('k'):(' ');
+	fprintf(stderr,"Best pulse: peak=%.7g, time=%.4g, period=%.4g, d_freq=%.12g, score=%.4g, chirp=%.5g, fft_len=%d%c\n",
+		best_pulse->p.peak_power,(best_pulse->p.time-swi.time_recorded)*86400,best_pulse->p.period,best_pulse->p.detection_freq,
+		best_pulse->score,best_pulse->p.chirp_rate,fft,symbol);
+  }
+  {
+	int fft=(best_triplet->t.fft_len>1024)?(best_triplet->t.fft_len/1024):(best_triplet->t.fft_len);
+	char symbol=(best_triplet->t.fft_len>1024)?('k'):(' ');
+	fprintf(stderr,"Best triplet: peak=%.7g, time=%.4g, period=%.4g, d_freq=%.12g, chirp=%.5g, fft_len=%d%c\n",
+		best_triplet->t.peak_power,(best_triplet->t.time-swi.time_recorded)*86400,best_triplet->t.period,best_triplet->t.detection_freq,
+		best_triplet->t.chirp_rate,fft,symbol);
+  }
+  }
+
   fprintf(stderr,"\nFlopcounter: %f\n\n", analysis_state.FLOP_counter);
   fprintf(stderr,"Spike count:    %d\n", spike_count);
   fprintf(stderr,"Autocorr count: %d\n", autocorr_count);
diff --git a/client/seti.h b/client/seti.h
index db55e3d..f2ba9f4 100644
--- a/client/seti.h
+++ b/client/seti.h
@@ -162,7 +162,7 @@ struct ANALYSIS_STATE {
 
 extern bool notranspose_flag;
 extern bool default_functions_flag;
-extern bool verbose;
+extern int verbose;
 extern int seti_init_state();
 extern int seti_do_work();
 extern int result_group_start();
diff --git a/client/seti_header.cpp b/client/seti_header.cpp
index 79c9a80..c5014bd 100644
--- a/client/seti_header.cpp
+++ b/client/seti_header.cpp
@@ -86,7 +86,7 @@ SETI_WU_INFO::SETI_WU_INFO(const workunit &w) :
     subband_number(w.subband_desc.number),
     receiver_cfg(w.group_info->receiver_cfg),
     nsamples(w.group_info->data_desc.nsamples),
-    bits_per_sample(w.group_info->recorder_cfg->bits_per_sample),
+    bits_per_sample(w.group_info->splitter_cfg->wu_bits_per_sample),
     position_history(w.group_info->data_desc.coords.begin()),
     num_positions(w.group_info->data_desc.coords.size()),
     analysis_cfg(w.group_info->analysis_cfg),
@@ -95,11 +95,15 @@ wu(&w) {
 #ifdef USE_MANUAL_CALLSTACK
   call_stack.enter("SETI_WU_INFO::SETI_WU_INFO(const workunit &w)");
 #endif /* USE_MANUAL_CALLSTACK */
+  // Adjust beam width for frequency
+  beam_width*=(w.group_info->receiver_cfg->center_freq*1e+6/subband_center);
+  if (bits_per_sample == 0) bits_per_sample=2;
+
   if (!strcmp(w.group_info->splitter_cfg->data_type,"ascii")) data_type = DATA_ASCII;
   else if (!strcmp(w.group_info->splitter_cfg->data_type,"encoded")) data_type = DATA_ENCODED;
   else if (!strcmp(w.group_info->splitter_cfg->data_type,"sun_binary")) data_type = DATA_SUN_BINARY;
   splitter_version=(int)floor(w.group_info->splitter_cfg->version)*0x100;
-  splitter_version+=(int)((w.group_info->splitter_cfg->version)*0x100) && 0xff;
+  splitter_version+=(int)((w.group_info->splitter_cfg->version)*0x100) & 0xff;
   angle_range=true_angle_range;
   sprintf(tape_version,"%8.2f",w.group_info->recorder_cfg->version);
 #ifdef USE_MANUAL_CALLSTACK
@@ -123,7 +127,7 @@ SETI_WU_INFO::SETI_WU_INFO() :
     ifft_len(0),
     subband_number(0),
     nsamples(0),
-    bits_per_sample(0),
+    bits_per_sample(2),
     position_history(),
     num_positions(0),
     beam_width(0) 
diff --git a/client/spike.cpp b/client/spike.cpp
index 1c48ff6..4f75186 100644
--- a/client/spike.cpp
+++ b/client/spike.cpp
@@ -134,6 +134,10 @@ int FindSpikes(
     // if best_spike.s.fft_len == 0, there is not yet a first spike
     if (si.score > best_spike->score || best_spike->s.fft_len == 0) {
       *best_spike 			= si;
+	  if(verbose>=2){
+      	fprintf(stderr,"New best spike:score:%.5g, power: %.5g, index=%d, fft_len=%d, ifft=%d,icfft=%d\n",
+	      si.score,si.s.peak_power,si.bin,si.s.fft_len,si.fft_ind,analysis_state.icfft);
+	  }
 #ifdef BOINC_APP_GRAPHICS
       if (!nographics()) sah_graphics->si.copy(&si);
 #endif
@@ -141,6 +145,12 @@ int FindSpikes(
 
     // Report a signal if it excceeds threshold.
     if (si.s.peak_power > (swi.analysis_cfg.spike_thresh)) {
+	  if(verbose>=1){
+      	int fft=(si.s.fft_len>1024)?(si.s.fft_len/1024):(si.s.fft_len);
+      	char symbol=(si.s.fft_len>1024)?('k'):(' ');
+      	fprintf(stderr,"Spike: peak=%.7g, time=%.4g, d_freq=%.12g, chirp=%.5g, fft_len=%d%c\n",
+	      si.s.peak_power,(si.s.time-swi.time_recorded)*86400,si.s.detection_freq,si.s.chirp_rate,fft,symbol);
+	  }
       retval = result_spike(si);
       if (retval) SETIERROR(retval,"from result_spike()");
     }
diff --git a/client/test_workunits/init_data.xml b/client/test_workunits/init_data.xml
new file mode 100644
index 0000000..4578808
--- /dev/null
+++ b/client/test_workunits/init_data.xml
@@ -0,0 +1,77 @@
+<app_init_data>
+<major_version>0</major_version>
+<minor_version>0</minor_version>
+<release>0</release>
+<app_version>0</app_version>
+<slot>987</slot>
+<wu_cpu_time>0</wu_cpu_time>
+<user_total_credit>0.000000</user_total_credit>
+<user_expavg_credit>0.000000</user_expavg_credit>
+<host_total_credit>0.000000</host_total_credit>
+<host_expavg_credit>0.000000</host_expavg_credit>
+<resource_share_fraction>0.000000</resource_share_fraction>
+<checkpoint_period>60.000000</checkpoint_period>
+<fraction_done_update_period>0.000000</fraction_done_update_period>
+<fraction_done_start>0.000000</fraction_done_start>
+<fraction_done_end>0.000000</fraction_done_end>
+<rsc_fpops_est>0.000000</rsc_fpops_est>
+<rsc_fpops_bound>0.000000</rsc_fpops_bound>
+<rsc_memory_bound>0.000000</rsc_memory_bound>
+<rsc_disk_bound>0.000000</rsc_disk_bound>
+<host_info>
+    <timezone>0</timezone>
+    <domain_name></domain_name>
+    <ip_addr></ip_addr>
+    <host_cpid></host_cpid>
+    <p_ncpus>0</p_ncpus>
+    <p_vendor></p_vendor>
+    <p_model></p_model>
+    <p_features></p_features>
+    <p_fpops>0.000000</p_fpops>
+    <p_iops>0.000000</p_iops>
+    <p_membw>0.000000</p_membw>
+    <p_calculated>0.000000</p_calculated>
+    <m_nbytes>134217728.000000</m_nbytes>
+    <m_cache>0.000000</m_cache>
+    <m_swap>0.000000</m_swap>
+    <d_total>0.000000</d_total>
+    <d_free>0.000000</d_free>
+    <os_name></os_name>
+    <os_version></os_version>
+    <accelerators></accelerators>
+</host_info>
+<proxy_info>
+    <socks_version>0</socks_version>
+    <socks_server_name></socks_server_name>
+    <socks_server_port>0</socks_server_port>
+    <http_server_name></http_server_name>
+    <http_server_port>0</http_server_port>
+    <socks5_user_name></socks5_user_name>
+    <socks5_user_passwd></socks5_user_passwd>
+    <http_user_name></http_user_name>
+    <http_user_passwd></http_user_passwd>
+</proxy_info>
+<global_preferences>
+   <mod_time>0</mod_time>
+   <suspend_if_no_recent_input>0.000000</suspend_if_no_recent_input>
+   <start_hour>0.000000</start_hour>
+   <end_hour>0.000000</end_hour>
+   <net_start_hour>0.000000</net_start_hour>
+   <net_end_hour>0.000000</net_end_hour>
+   <work_buf_min_days>0.000010</work_buf_min_days>
+   <work_buf_additional_days>0.250000</work_buf_additional_days>
+   <max_cpus>1</max_cpus>
+   <cpu_scheduling_period_minutes>60.000000</cpu_scheduling_period_minutes>
+   <disk_interval>0.000000</disk_interval>
+   <disk_max_used_gb>0.000000</disk_max_used_gb>
+   <disk_max_used_pct>0.000000</disk_max_used_pct>
+   <disk_min_free_gb>0.000000</disk_min_free_gb>
+   <vm_max_used_pct>0.000000</vm_max_used_pct>
+   <ram_max_used_busy_pct>50.000000</ram_max_used_busy_pct>
+   <ram_max_used_idle_pct>90.000000</ram_max_used_idle_pct>
+   <idle_time_to_run>0.000000</idle_time_to_run>
+   <max_bytes_sec_up>1000000000000.000000</max_bytes_sec_up>
+   <max_bytes_sec_down>1000000000000.000000</max_bytes_sec_down>
+   <cpu_usage_limit>100.000000</cpu_usage_limit>
+</global_preferences>
+</app_init_data>
diff --git a/client/test_workunits/reference_result_unit.sah b/client/test_workunits/reference_result_unit.sah
index a621272..bd18166 100644
--- a/client/test_workunits/reference_result_unit.sah
+++ b/client/test_workunits/reference_result_unit.sah
@@ -168,12 +168,13 @@
       <fft_len>2048</fft_len>
       <ifft_len>8</ifft_len>
       <filter>fft</filter>
-      <window>welsh</window>
-      <samples_per_wu>0</samples_per_wu>
+      <window>hanning</window>
+      <samples_per_wu>1048576</samples_per_wu>
       <highpass>0</highpass>
-      <blanker_filter></blanker_filter>
-      <pfb_ntaps>0</pfb_ntaps>
-      <pfb_width_factor>0</pfb_width_factor>
+      <blanker_filter>randomize</blanker_filter>
+      <pfb_ntaps>16</pfb_ntaps>
+      <pfb_width_factor>1.04999995</pfb_width_factor>
+      <wu_bits_per_sample>2</wu_bits_per_sample>
     </splitter_cfg>
     <analysis_cfg>
       <spike_thresh>22</spike_thresh>
@@ -192,7 +193,7 @@
       <pulse_min>16</pulse_min>
       <pulse_fft_max>8192</pulse_fft_max>
       <pulse_pot_length>256</pulse_pot_length>
-      <triplet_thresh>8.45</triplet_thresh>
+      <triplet_thresh>8.25</triplet_thresh>
       <triplet_max>131072</triplet_max>
       <triplet_min>16</triplet_min>
       <triplet_pot_length>256</triplet_pot_length>
@@ -237,8 +238,8 @@
 <sb_id>0</sb_id>
 </workunit_header>
 <triplet>
-  <peak_power>8.7894258499146</peak_power>
-  <mean_power>0.0077550648711622</mean_power>
+  <peak_power>8.6426544189453</peak_power>
+  <mean_power>0.0078867627307773</mean_power>
   <time>2451606.8592904</time>
   <ra>14.89751995747</ra>
   <decl>28.57</decl>
@@ -254,7 +255,7 @@
   <period>0.54394906759262</period>
 </triplet>
 <spike>
-  <peak_power>22.395505905151</peak_power>
+  <peak_power>22.395553588867</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8595251</time>
   <ra>14.909502836654</ra>
@@ -270,7 +271,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>22.534965515137</peak_power>
+  <peak_power>22.535062789917</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8595251</time>
   <ra>14.909502836654</ra>
@@ -286,7 +287,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>22.37899017334</peak_power>
+  <peak_power>22.378698348999</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8587484</time>
   <ra>14.871418063004</ra>
@@ -302,7 +303,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>22.36404800415</peak_power>
+  <peak_power>22.364013671875</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8594668</time>
   <ra>14.906409847822</ra>
@@ -318,7 +319,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>22.462232589722</peak_power>
+  <peak_power>22.462213516235</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8594668</time>
   <ra>14.906409847822</ra>
@@ -334,7 +335,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>22.140871047974</peak_power>
+  <peak_power>22.140769958496</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8593697</time>
   <ra>14.90148701969</ra>
@@ -350,7 +351,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>22.10387802124</peak_power>
+  <peak_power>22.104068756104</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.858593</time>
   <ra>14.864150850996</ra>
@@ -366,7 +367,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>23.334806442261</peak_power>
+  <peak_power>23.334712982178</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.858593</time>
   <ra>14.864150850996</ra>
@@ -382,7 +383,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>23.518405914307</peak_power>
+  <peak_power>23.518535614014</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.858593</time>
   <ra>14.864150850996</ra>
@@ -398,7 +399,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>22.629114151001</peak_power>
+  <peak_power>22.629072189331</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.858593</time>
   <ra>14.864150850996</ra>
@@ -414,7 +415,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>22.818519592285</peak_power>
+  <peak_power>22.818777084351</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8584377</time>
   <ra>14.856922413057</ra>
@@ -430,7 +431,7 @@
   <reserved>0</reserved>
 </spike>
 <spike>
-  <peak_power>23.786426544189</peak_power>
+  <peak_power>23.786548614502</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8584377</time>
   <ra>14.856922413057</ra>
@@ -446,7 +447,7 @@
   <reserved>0</reserved>
 </spike>
 <autocorr>
-  <peak_power>17.814985275269</peak_power>
+  <peak_power>17.814907073975</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8584377</time>
   <ra>14.856922413057</ra>
@@ -463,7 +464,7 @@
   <reserved>0</reserved>
 </autocorr>
 <spike>
-  <peak_power>22.056993484497</peak_power>
+  <peak_power>22.051849365234</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8589037</time>
   <ra>14.879185317697</ra>
@@ -478,34 +479,187 @@
   <rfi_found>0</rfi_found>
   <reserved>0</reserved>
 </spike>
-<pulse>
-  <peak_power>6.2925500869751</peak_power>
-  <mean_power>0.032650236040354</mean_power>
-  <time>2451606.8594817</time>
-  <ra>14.907301879412</ra>
-  <decl>28.58</decl>
+<triplet>
+  <peak_power>10.885553359985</peak_power>
+  <mean_power>0.0038262107409537</mean_power>
+  <time>2451606.8584958</time>
+  <ra>14.859288741085</ra>
+  <decl>28.56</decl>
   <q_pix>0</q_pix>
-  <freq>1418921813.9569</freq>
-  <detection_freq>1418918837.2224</detection_freq>
+  <freq>1418919067.3762</freq>
+  <detection_freq>1418918701.9642</detection_freq>
   <barycentric_freq>0</barycentric_freq>
-  <fft_len>512</fft_len>
-  <chirp_rate>-30.714999066808</chirp_rate>
+  <fft_len>64</fft_len>
+  <chirp_rate>-31.14940113594</chirp_rate>
   <rfi_checked>0</rfi_checked>
   <rfi_found>0</rfi_found>
   <reserved>0</reserved>
-  <period>2.3592972755432</period>
-  <snr>14.070569992065</snr>
-  <thresh>13.400217056274</thresh>
+  <period>4.2041363716125</period>
+</triplet>
+<gaussian>
+  <peak_power>3.1083626747131</peak_power>
+  <mean_power>0.57625639438629</mean_power>
+  <time>2451606.8589911</time>
+  <ra>14.883054389246</ra>
+  <decl>28.57</decl>
+  <q_pix>0</q_pix>
+  <freq>1418915821.905</freq>
+  <detection_freq>1418917957.8961</detection_freq>
+  <barycentric_freq>0</barycentric_freq>
+  <fft_len>16384</fft_len>
+  <chirp_rate>39.173824038504</chirp_rate>
+  <rfi_checked>0</rfi_checked>
+  <rfi_found>0</rfi_found>
+  <reserved>0</reserved>
+  <sigma>3.5095455646515</sigma>
+  <chisqr>1.4116749763489</chisqr>
+  <null_chisqr>2.1085500717163</null_chisqr>
   <score>0</score>
-  <len_prof>45</len_prof>
-  <pot length=145 encoding="x-csv">
-    35,15,31,33,30,255,28,53,31,31,17,17,37,23,21,17,33,39,17,12,21,9,14,27,
-    14,13,29,23,0,24,54,32,22,28,16,29,5,24,48,30,37,38,28,24,51
+  <max_power>9.5103559494019</max_power>
+  <pot length=183 encoding="x-csv">
+    7,9,13,28,18,7,3,7,1,0,28,33,5,1,8,15,13,12,2,14,13,2,6,57,14,9,0,22,0,
+    59,2,63,255,200,71,60,24,83,75,2,52,31,0,6,11,27,7,0,1,21,3,62,1,41,52,
+    2,19,3,17,8,24,41,28,18
+  </pot>
+</gaussian>
+
+<gaussian>
+  <peak_power>3.3304581642151</peak_power>
+  <mean_power>0.56233322620392</mean_power>
+  <time>2451606.8590105</time>
+  <ra>14.884025293173</ra>
+  <decl>28.57</decl>
+  <q_pix>0</q_pix>
+  <freq>1418915821.905</freq>
+  <detection_freq>1418918023.6189</detection_freq>
+  <barycentric_freq>0</barycentric_freq>
+  <fft_len>16384</fft_len>
+  <chirp_rate>39.173824038504</chirp_rate>
+  <rfi_checked>0</rfi_checked>
+  <rfi_found>0</rfi_found>
+  <reserved>0</reserved>
+  <sigma>3.5095455646515</sigma>
+  <chisqr>1.3641883134842</chisqr>
+  <null_chisqr>2.1419405937195</null_chisqr>
+  <score>0</score>
+  <max_power>9.5103559494019</max_power>
+  <pot length=183 encoding="x-csv">
+    7,9,13,28,18,7,3,7,1,0,28,33,5,1,8,15,13,12,2,14,13,2,6,57,14,9,0,22,0,
+    59,2,63,255,200,71,60,24,83,75,2,52,31,0,6,11,27,7,0,1,21,3,62,1,41,52,
+    2,19,3,17,8,24,41,28,18
+  </pot>
+</gaussian>
+
+<gaussian>
+  <peak_power>3.202214717865</peak_power>
+  <mean_power>0.56919771432877</mean_power>
+  <time>2451606.8590299</time>
+  <ra>14.884996197099</ra>
+  <decl>28.57</decl>
+  <q_pix>0</q_pix>
+  <freq>1418915821.905</freq>
+  <detection_freq>1418918089.3417</detection_freq>
+  <barycentric_freq>0</barycentric_freq>
+  <fft_len>16384</fft_len>
+  <chirp_rate>39.173824038504</chirp_rate>
+  <rfi_checked>0</rfi_checked>
+  <rfi_found>0</rfi_found>
+  <reserved>0</reserved>
+  <sigma>3.5095455646515</sigma>
+  <chisqr>1.411563873291</chisqr>
+  <null_chisqr>2.1597337722778</null_chisqr>
+  <score>0</score>
+  <max_power>9.5103559494019</max_power>
+  <pot length=183 encoding="x-csv">
+    7,9,13,28,18,7,3,7,1,0,28,33,5,1,8,15,13,12,2,14,13,2,6,57,14,9,0,22,0,
+    59,2,63,255,200,71,60,24,83,75,2,52,31,0,6,11,27,7,0,1,21,3,62,1,41,52,
+    2,19,3,17,8,24,41,28,18
   </pot>
-</pulse>
+</gaussian>
+
+<gaussian>
+  <peak_power>3.2735865116119</peak_power>
+  <mean_power>0.52121621370316</mean_power>
+  <time>2451606.8592629</time>
+  <ra>14.896431365397</ra>
+  <decl>28.57</decl>
+  <q_pix>0</q_pix>
+  <freq>1418916015.024</freq>
+  <detection_freq>1418919872.9451</detection_freq>
+  <barycentric_freq>0</barycentric_freq>
+  <fft_len>16384</fft_len>
+  <chirp_rate>49.451592142226</chirp_rate>
+  <rfi_checked>0</rfi_checked>
+  <rfi_found>0</rfi_found>
+  <reserved>0</reserved>
+  <sigma>3.5095455646515</sigma>
+  <chisqr>1.3751286268234</chisqr>
+  <null_chisqr>2.3200657367706</null_chisqr>
+  <score>0</score>
+  <max_power>9.5516929626465</max_power>
+  <pot length=190 encoding="x-csv">
+    13,63,10,5,12,6,7,5,8,8,2,14,6,24,41,10,22,5,4,20,13,0,12,18,27,12,12,
+    16,18,9,29,1,1,28,7,2,13,1,1,32,47,96,9,4,4,71,193,127,255,87,35,42,12,
+    28,12,5,22,12,19,27,10,11,26,18
+  </pot>
+</gaussian>
+
+<gaussian>
+  <peak_power>3.6199193000793</peak_power>
+  <mean_power>0.51788127422333</mean_power>
+  <time>2451606.8592824</time>
+  <ra>14.897117952021</ra>
+  <decl>28.57</decl>
+  <q_pix>0</q_pix>
+  <freq>1418916015.024</freq>
+  <detection_freq>1418919955.9112</detection_freq>
+  <barycentric_freq>0</barycentric_freq>
+  <fft_len>16384</fft_len>
+  <chirp_rate>49.451592142226</chirp_rate>
+  <rfi_checked>0</rfi_checked>
+  <rfi_found>0</rfi_found>
+  <reserved>0</reserved>
+  <sigma>3.5095455646515</sigma>
+  <chisqr>1.2605501413345</chisqr>
+  <null_chisqr>2.2607674598694</null_chisqr>
+  <score>0</score>
+  <max_power>9.5516929626465</max_power>
+  <pot length=190 encoding="x-csv">
+    13,63,10,5,12,6,7,5,8,8,2,14,6,24,41,10,22,5,4,20,13,0,12,18,27,12,12,
+    16,18,9,29,1,1,28,7,2,13,1,1,32,47,96,9,4,4,71,193,127,255,87,35,42,12,
+    28,12,5,22,12,19,27,10,11,26,18
+  </pot>
+</gaussian>
+
+<gaussian>
+  <peak_power>3.5863273143768</peak_power>
+  <mean_power>0.52562576532364</mean_power>
+  <time>2451606.8593018</time>
+  <ra>14.898088855948</ra>
+  <decl>28.57</decl>
+  <q_pix>0</q_pix>
+  <freq>1418916015.024</freq>
+  <detection_freq>1418920038.8772</detection_freq>
+  <barycentric_freq>0</barycentric_freq>
+  <fft_len>16384</fft_len>
+  <chirp_rate>49.451592142226</chirp_rate>
+  <rfi_checked>0</rfi_checked>
+  <rfi_found>0</rfi_found>
+  <reserved>0</reserved>
+  <sigma>3.5095455646515</sigma>
+  <chisqr>1.3370245695114</chisqr>
+  <null_chisqr>2.2789671421051</null_chisqr>
+  <score>0</score>
+  <max_power>9.5516929626465</max_power>
+  <pot length=190 encoding="x-csv">
+    13,63,10,5,12,6,7,5,8,8,2,14,6,24,41,10,22,5,4,20,13,0,12,18,27,12,12,
+    16,18,9,29,1,1,28,7,2,13,1,1,32,47,96,9,4,4,71,193,127,255,87,35,42,12,
+    28,12,5,22,12,19,27,10,11,26,18
+  </pot>
+</gaussian>
 
 <best_spike>
-  <peak_power>23.786426544189</peak_power>
+  <peak_power>23.786548614502</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8584377</time>
   <ra>14.856922413057</ra>
@@ -521,7 +675,7 @@
   <reserved>0</reserved>
 </best_spike>
 <best_autocorr>
-  <peak_power>17.814985275269</peak_power>
+  <peak_power>17.814907073975</peak_power>
   <mean_power>1</mean_power>
   <time>2451606.8584377</time>
   <ra>14.856922413057</ra>
@@ -538,71 +692,72 @@
   <reserved>0</reserved>
 </best_autocorr>
 <best_gaussian>
-  <peak_power>3.1875100135803</peak_power>
-  <mean_power>0.56233388185501</mean_power>
-  <time>2451606.8590105</time>
-  <ra>14.884025293173</ra>
+  <peak_power>3.6199193000793</peak_power>
+  <mean_power>0.51788127422333</mean_power>
+  <time>2451606.8592824</time>
+  <ra>14.897117952021</ra>
   <decl>28.57</decl>
   <q_pix>0</q_pix>
-  <freq>1418915821.905</freq>
-  <detection_freq>1418918023.6189</detection_freq>
+  <freq>1418916015.024</freq>
+  <detection_freq>1418919955.9112</detection_freq>
   <barycentric_freq>0</barycentric_freq>
   <fft_len>16384</fft_len>
-  <chirp_rate>39.173824038504</chirp_rate>
+  <chirp_rate>49.451592142226</chirp_rate>
   <rfi_checked>0</rfi_checked>
   <rfi_found>0</rfi_found>
   <reserved>0</reserved>
-  <sigma>4.1290321350098</sigma>
-  <chisqr>1.3583942651749</chisqr>
-  <null_chisqr>2.09810090065</null_chisqr>
+  <sigma>3.5095455646515</sigma>
+  <chisqr>1.2605501413345</chisqr>
+  <null_chisqr>2.2607674598694</null_chisqr>
   <score>0</score>
-  <max_power>9.5103549957275</max_power>
-  <pot length=183 encoding="x-csv">
-    7,9,13,28,18,7,3,7,1,0,28,33,5,1,8,15,13,12,2,14,13,2,6,57,14,9,0,22,0,
-    59,2,63,255,200,71,60,24,83,75,2,52,31,0,6,11,27,7,0,1,21,3,62,1,41,52,
-    2,19,3,17,8,24,41,28,18
+  <max_power>9.5516929626465</max_power>
+  <pot length=190 encoding="x-csv">
+    13,63,10,5,12,6,7,5,8,8,2,14,6,24,41,10,22,5,4,20,13,0,12,18,27,12,12,
+    16,18,9,29,1,1,28,7,2,13,1,1,32,47,96,9,4,4,71,193,127,255,87,35,42,12,
+    28,12,5,22,12,19,27,10,11,26,18
   </pot>
 </best_gaussian>
 <best_pulse>
-  <peak_power>6.2925500869751</peak_power>
-  <mean_power>0.032650236040354</mean_power>
+  <peak_power>5.9889302253723</peak_power>
+  <mean_power>0.033245835453272</mean_power>
   <time>2451606.8594817</time>
   <ra>14.907301879412</ra>
   <decl>28.58</decl>
   <q_pix>0</q_pix>
   <freq>1418921813.9569</freq>
-  <detection_freq>1418918837.2224</detection_freq>
+  <detection_freq>1418918839.5513</detection_freq>
   <barycentric_freq>0</barycentric_freq>
   <fft_len>512</fft_len>
-  <chirp_rate>-30.714999066808</chirp_rate>
+  <chirp_rate>-30.690968314047</chirp_rate>
   <rfi_checked>0</rfi_checked>
   <rfi_found>0</rfi_found>
   <reserved>0</reserved>
   <period>2.3592972755432</period>
-  <snr>14.070569992065</snr>
-  <thresh>13.400217056274</thresh>
+  <snr>13.391654968262</snr>
+  <thresh>13.4002161026</thresh>
   <score>0</score>
   <len_prof>45</len_prof>
-  <pot length=145 encoding="x-csv">
-    35,15,31,33,30,255,28,53,31,31,17,17,37,23,21,17,33,39,17,12,21,9,14,27,
-    14,13,29,23,0,24,54,32,22,28,16,29,5,24,48,30,37,38,28,24,51
+  <pot length=146 encoding="x-csv">
+    40,10,41,34,32,255,28,55,33,38,21,22,40,30,23,22,36,43,16,21,21,11,17,
+    23,12,17,38,26,0,23,53,24,25,21,15,29,3,22,46,34,36,31,28,26,51
   </pot>
 </best_pulse>
 <best_triplet>
-  <peak_power>8.7894258499146</peak_power>
-  <mean_power>0.0077550648711622</mean_power>
-  <time>2451606.8592904</time>
-  <ra>14.89751995747</ra>
-  <decl>28.57</decl>
+  <peak_power>10.885553359985</peak_power>
+  <mean_power>0.0038262107409537</mean_power>
+  <time>2451606.8584958</time>
+  <ra>14.859288741085</ra>
+  <decl>28.56</decl>
   <q_pix>0</q_pix>
-  <freq>1418924789.4192</freq>
-  <detection_freq>1418924863.1228</detection_freq>
+  <freq>1418919067.3762</freq>
+  <detection_freq>1418918701.9642</detection_freq>
   <barycentric_freq>0</barycentric_freq>
-  <fft_len>128</fft_len>
-  <chirp_rate>0.9168656437853</chirp_rate>
+  <fft_len>64</fft_len>
+  <chirp_rate>-31.14940113594</chirp_rate>
   <rfi_checked>0</rfi_checked>
   <rfi_found>0</rfi_found>
   <reserved>0</reserved>
-  <period>0.54394906759262</period>
+  <period>4.2041363716125</period>
 </best_triplet>
+<setiathome_version>8.00</setiathome_version>
 </result>
\ No newline at end of file
diff --git a/client/test_workunits/reference_work_unit.sah b/client/test_workunits/reference_work_unit.sah
index 1482ed7..26efee8 100644
--- a/client/test_workunits/reference_work_unit.sah
+++ b/client/test_workunits/reference_work_unit.sah
@@ -1,4 +1,5 @@
 <workunit>
+<app_name>setiathome_v8</app_name>
 <workunit_header>
 <name>reference.wu</name>
 <group_info>
@@ -150,7 +151,13 @@
     <fft_len>2048</fft_len>
     <ifft_len>8</ifft_len>
     <filter>fft</filter>
-    <window>welsh</window>
+    <window>hanning</window>
+    <samples_per_wu>1048576</samples_per_wu>
+    <highpass>0</highpass>
+    <blanker_filter>randomize</blanker_filter>
+    <pfb_ntaps>16</pfb_ntaps>
+    <pfb_width_factor>1.04999995</pfb_width_factor>
+    <wu_bits_per_sample>2</wu_bits_per_sample>
   </splitter_cfg>
   <analysis_cfg>
      <spike_thresh>22.0</spike_thresh>
@@ -169,7 +176,7 @@
      <pulse_min>16</pulse_min>
      <pulse_fft_max>8192</pulse_fft_max>
      <pulse_pot_length>256</pulse_pot_length>
-     <triplet_thresh>8.450</triplet_thresh>
+     <triplet_thresh>8.250</triplet_thresh>
      <triplet_min>16</triplet_min>
      <triplet_max>131072</triplet_max>
      <triplet_pot_length>256</triplet_pot_length>
diff --git a/client/test_workunits/seti_logo b/client/test_workunits/seti_logo
new file mode 100644
index 0000000..006f324
Binary files /dev/null and b/client/test_workunits/seti_logo differ
diff --git a/client/test_workunits/sponsor_bkg b/client/test_workunits/sponsor_bkg
new file mode 100755
index 0000000..4b5be62
Binary files /dev/null and b/client/test_workunits/sponsor_bkg differ
diff --git a/client/test_workunits/sponsor_logo b/client/test_workunits/sponsor_logo
new file mode 100644
index 0000000..a79d981
Binary files /dev/null and b/client/test_workunits/sponsor_logo differ
diff --git a/client/vector/analyzeFuncs_avx.cpp b/client/vector/analyzeFuncs_avx.cpp
index a7fe3bd..e55eea7 100644
--- a/client/vector/analyzeFuncs_avx.cpp
+++ b/client/vector/analyzeFuncs_avx.cpp
@@ -23,6 +23,8 @@
 // with SETI_BOINC; see the file COPYING.  If not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+#define USE_MATH_DEFINES
+
 #include "sah_config.h"
 
 //JWS: For a release build using this module, compile with -mavx on GCC 4.4 or
@@ -58,6 +60,10 @@
 #include "x86_ops.h"
 #include "pulsefind.h"
 
+#ifndef M_PI
+   #define M_PI 3.14159265358979323846
+#endif
+
 // =============================================================================
 // JWS: Four variant chirp functions, first expands constants in memory
 //
@@ -1140,7 +1146,7 @@ float foldBy3(float *ss[], struct PoTPlan *P) {
     x2 = _mm256_add_ps(x1, *(__m256*)(p2+i));
     x1 = _mm256_add_ps(x2, *(__m256*)(p3+i));
 
-    tailmask = _mm256_cmp_ps(taillim, tailelem, 0x0d);  // taillim floats >= tailelem floats
+    tailmask = _mm256_cmp_ps(taillim, tailelem, 0x0d);  // taillim floats >= tailelem floats 
     _mm256_maskstore_ps(pst+i, AVX_MASKSTORE_TYPECAST(tailmask), x1);
     x2 = _mm256_and_ps(x1, tailmask);
     maxV = _mm256_max_ps(maxV, x2);
diff --git a/client/vector/analyzeFuncs_vector.cpp b/client/vector/analyzeFuncs_vector.cpp
index b2b9830..a39a7e3 100644
--- a/client/vector/analyzeFuncs_vector.cpp
+++ b/client/vector/analyzeFuncs_vector.cpp
@@ -38,10 +38,6 @@
 
 #include "sah_config.h" 
 
-#ifdef __APPLE_CC__
-#define _CPP_CMATH  // Block inclusion of <cmath> which undefines isnan() (for using GCC 3 on OS X)
-#define _GLIBCXX_CMATH  // Block inclusion of <cmath> which undefines isnan() (for using GCC 4 on OS X)
-#endif
 #ifdef _WIN32
 #define uint32_t unsigned long
 #endif
@@ -49,6 +45,9 @@
 #include <csignal>
 #include <cstdlib>
 #include <cmath>
+#ifdef __APPLE_CC__
+#define isnan std::isnan
+#endif
 #include <signal.h>
 #include <setjmp.h>
 #ifdef HAVE_FLOAT_H
@@ -60,6 +59,7 @@
 #ifdef HAVE_IEEEFP_H
 #include <ieeefp.h>
 #endif
+#include <numeric>
 
 #include "util.h"
 #include "s_util.h"
@@ -153,7 +153,15 @@ int avxSupported(void) {
     call_stack.enter("avxSupported()");
 #endif 
     int retval = 1;
-#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ > 3)) || (__GNUC__ > 4))
+#if defined(__APPLE_CC__)
+    int avx1=0;
+    int avx2=0;
+    size_t length=sizeof(int);
+    int error;
+    error=sysctlbyname("hw.optional.avx1_0",&avx1,&length,NULL,0);
+    error=sysctlbyname("hw.optional.avx2_0",&avx2,&length,NULL,0);
+    retval=(avx1||avx2);
+#elif defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ > 3)) || (__GNUC__ > 4))
 #if defined(__i386__) && (defined(__PIC__) || defined(__pic__))
 // EBX can't be clobbered on linux PIC.
     __asm__ ( "pushl %ebx \n\t" );
@@ -174,7 +182,7 @@ int avxSupported(void) {
         "1: \n\t"
         "movl   $0, %0 \n\t"
         "2: \n\t"
-#  if defined(_WIN64) || defined(__LP64__) || defined (__X86_64__)
+#  if defined(_WIN64) || defined(__LP64__) || defined (__x86_64__)
         : "=g" (retval) :: "%rax", "%rbx", "%rcx", "%rdx"
 #  elif defined(__i386__) && (defined(__PIC__) || defined(__pic__))
         "popl %%ebx \n\t"
@@ -270,7 +278,7 @@ void SetCapabilities(void) {
 
 #if defined(ANDROID) ||  defined(__linux__)
   // if strlen(p_features) is 0 or p_features doesn't contain "vfp" assume
-  // either BOINC is screwed up or we're running stand along.
+  // either BOINC is screwed up or we're running stand alone.
   size_t len=strlen(app_init_data.host_info.p_features);
   if ((len==0) || (strstr(app_init_data.host_info.p_features,"vfp") == 0)) {
     if (do_print) fprintf(stderr,"Getting CPU Capabilities from /proc/cpuinfo\n");
@@ -361,20 +369,31 @@ bool found_get_power_spectrum=false;
 
 CDtb ChirpDataFuncs[]={
     v_ChirpData, BA_ANY, "v_ChirpData",
+#if !defined(__x86_64__) && !defined(_M_AMD64)  && !defined(X86_64)
     fpu_ChirpData, BA_ANY, "fpu_ChirpData",
     fpu_opt_ChirpData, BA_ANY, "fpu_opt_ChirpData",
+#endif
 #ifdef USE_ALTIVEC
     v_vChirpData, BA_ALTVC, "v_vChirpData",  
     v_vChirpDataG4, BA_ALTVC, "v_vChirpDataG4",
     v_vChirpDataG5, BA_ALTVC, "v_vChirpDataG5",
 #endif
 #ifdef USE_SSE 
+#if defined(__x86_64__) || defined(_M_AMD64)  || defined(X86_64)
+    v_vChirpData_x86_64, BA_ANY, "v_vChirpData_x86_64",
+    sse1_ChirpData_ak, BA_ANY, "sse1_ChirpData_ak",
+    sse1_ChirpData_ak8e, BA_ANY, "sse1_ChirpData_ak8e",
+    sse1_ChirpData_ak8h, BA_ANY, "sse1_ChirpData_ak8h",
+    sse2_ChirpData_ak, BA_ANY, "sse2_ChirpData_ak",
+    sse2_ChirpData_ak8, BA_ANY, "sse2_ChirpData_ak8",
+#else
     v_vChirpData_x86_64, BA_SSE2, "v_vChirpData_x86_64",
     sse1_ChirpData_ak, BA_SSE, "sse1_ChirpData_ak",
     sse1_ChirpData_ak8e, BA_SSE, "sse1_ChirpData_ak8e",
     sse1_ChirpData_ak8h, BA_SSE, "sse1_ChirpData_ak8h",
     sse2_ChirpData_ak, BA_SSE2, "sse2_ChirpData_ak",
     sse2_ChirpData_ak8, BA_SSE2, "sse2_ChirpData_ak8",
+#endif
     sse3_ChirpData_ak, BA_SSE3, "sse3_ChirpData_ak",
     sse3_ChirpData_ak8, BA_SSE3, "sse3_ChirpData_ak8",
 #endif
@@ -409,6 +428,9 @@ TPtb TransposeFuncs[]={
     v_Transpose2, BA_ANY, "v_Transpose2",
     v_Transpose4, BA_ANY, "v_Transpose4",
     v_Transpose8, BA_ANY, "v_Transpose8",
+#ifdef USE_FFTWF
+    fftwf_transpose, BA_ANY, "fftwf_transpose",
+#endif
 #ifdef USE_ALTIVEC
     v_vTranspose, BA_ALTVC, "v_vTranspose",
 #endif
@@ -545,14 +567,16 @@ BaseLineSmooth_func ChooseBaseLineSmooth() {
     BaseLineSmooth_func baseline_smooth;
     int i,j,rv,k = sizeof(BaseLineSmoothFuncs)/sizeof(BLStb);
     int NumDataPoints=128*1024;
-    double speed=1e+6,timing,accuracy;
+    double speed=1e+6,timing,onetime,accuracy;
+    std::vector<double> timings;
+    timings.reserve(1000);
     int best;
     double best_timing, best_accuracy;
 
     if (k == 1) {
       if (do_print) fprintf(stderr,"%32s (no other)%s\n",
                                     BaseLineSmoothFuncs[0].nom,
-                                    verbose ? "\n": "");
+                                    (verbose>1) ? "\n": "");
 #ifdef USE_MANUAL_CALLSTACK
       call_stack.exit();
 #endif 
@@ -587,7 +611,7 @@ BaseLineSmooth_func ChooseBaseLineSmooth() {
     for (i=0;i<k;i++) {
 #endif
             if (!(CPUCaps & BaseLineSmoothFuncs[i].ba)) {
-                if (verbose)
+                if (verbose>1)
                     fprintf(stderr,"%32s not supported on CPU\n",
                                    BaseLineSmoothFuncs[i].nom);
                 continue;
@@ -595,11 +619,13 @@ BaseLineSmooth_func ChooseBaseLineSmooth() {
     
             j=0;
             timing=0;
-            while ((j<40) && ((j<4) || (timing<(3*timer.resolution())))) {
+            while ((j<100) && ((j<20) || (timing<(10*timer.resolution())))) {
                 memcpy(outdata,indata,NumDataPoints*sizeof(sah_complex));
                 timer.start();
                 rv=BaseLineSmoothFuncs[i].func(outdata,NumDataPoints,8192,32768);
-                timing+=timer.stop();
+                onetime=timer.stop();
+                timing+=onetime;
+                timings.push_back(onetime);
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
                 if (rv) siglongjmp(jb,1);
 #else
@@ -608,7 +634,10 @@ BaseLineSmooth_func ChooseBaseLineSmooth() {
                 j++;
             }
             if (rv) continue;
-            timing/=j;
+            std::sort(timings.begin(),timings.end());
+            timing=timings[timings.size()/2];
+            if (timing==0) timing=std::accumulate(timings.begin(),timings.end(),0.0)/timings.size();
+            timings.clear();
             if (i==0) {
                 accuracy=0;
                 memcpy(save,outdata,NumDataPoints*sizeof(sah_complex));
@@ -619,7 +648,7 @@ BaseLineSmooth_func ChooseBaseLineSmooth() {
                     accuracy+=pow(save[j][1]-outdata[j][1],2);
                 }
             }
-            if (verbose) {
+            if (verbose>1) {
                 fprintf(stderr,"%32s %8.6f %7.5f  test\n",BaseLineSmoothFuncs[i].nom,timing,accuracy);
                 fflush(stderr);
             }
@@ -633,7 +662,7 @@ BaseLineSmooth_func ChooseBaseLineSmooth() {
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
         } else {
             // reinstall_sighandler();
-            if (verbose) {
+            if (verbose>1) {
                 fprintf(stderr,"%32s faulted\n",BaseLineSmoothFuncs[i].nom);
                 fflush(stderr);
 	    }
@@ -651,7 +680,7 @@ BaseLineSmooth_func ChooseBaseLineSmooth() {
              BaseLineSmoothFuncs[best].nom,
              best_timing,
              best_accuracy,
-             verbose ? " choice\n": "");
+             (verbose>1) ? " choice\n": "");
 #ifdef USE_MANUAL_CALLSTACK
     call_stack.exit();
 #endif 
@@ -673,7 +702,9 @@ GetPowerSpectrum_func ChooseGetPowerSpectrum() {
     hires_timer timer;
     GetPowerSpectrum_func get_power_spectrum;
     int i,j,rv;
-    double speed=1e+6,timing,mintime,onetime,accuracy;
+    double speed=1e+6,timing,onetime,accuracy;
+    std::vector<double> timings;
+    timings.reserve(1000);
     int NumDataPoints=128*1024;
     int best;
     double best_timing, best_accuracy;
@@ -706,21 +737,20 @@ GetPowerSpectrum_func ChooseGetPowerSpectrum() {
     for (i=0;(i*sizeof(GPStb))<sizeof(GetPowerSpectrumFuncs);i++) {
 #endif
             if (!(CPUCaps & GetPowerSpectrumFuncs[i].ba)) {
-                if (verbose)
+                if (verbose>1)
                     fprintf(stderr,"%32s not supported on CPU\n",
                                    GetPowerSpectrumFuncs[i].nom);
                 continue;
             }
             j=0;
             timing=0;
-            mintime=1e6;
-            while ((j<100) && ((j<10) || (timing<(3*timer.resolution())))) {
+            while ((j<100) && ((j<20) || (timing<(10*timer.resolution())))) {
                 memset(outdata,0,NumDataPoints*sizeof(float));
                 timer.start();
                 rv=GetPowerSpectrumFuncs[i].func(indata,outdata,NumDataPoints);
                 onetime=timer.stop();
                 timing+=onetime;
-                if (onetime<mintime) mintime=onetime;
+                timings.push_back(onetime);
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
                 if (rv) siglongjmp(jb,1);
 #else
@@ -729,8 +759,11 @@ GetPowerSpectrum_func ChooseGetPowerSpectrum() {
                 j++;
             }
             if (rv) continue;
-            timing/=j;
-            timing = (timing+mintime)/2;
+            
+            std::sort(timings.begin(),timings.end());
+            timing=timings[timings.size()/2];
+            if (timing==0) timing=std::accumulate(timings.begin(),timings.end(),0.0)/timings.size();
+            timings.clear();
             if (i==0) {
                 accuracy=0;
                 memcpy(save,outdata,NumDataPoints*sizeof(float));
@@ -741,7 +774,7 @@ GetPowerSpectrum_func ChooseGetPowerSpectrum() {
                 }
                 accuracy=sqrt(accuracy);
             }
-            if (verbose) {
+            if (verbose>1) {
                 fprintf(stderr,"%32s %8.6f %7.5f  test\n",GetPowerSpectrumFuncs[i].nom,timing,accuracy);
                 fflush(stderr);
             }
@@ -755,7 +788,7 @@ GetPowerSpectrum_func ChooseGetPowerSpectrum() {
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
         } else {
             // reinstall_sighandler();
-            if (verbose) {
+            if (verbose>1) {
                 fprintf(stderr,"%32s faulted\n",GetPowerSpectrumFuncs[i].nom);
                 fflush(stderr);
             }
@@ -773,7 +806,7 @@ GetPowerSpectrum_func ChooseGetPowerSpectrum() {
                       GetPowerSpectrumFuncs[best].nom,
                       best_timing,
                       best_accuracy,
-                      verbose ? " choice\n": "");
+                      (verbose>1) ? " choice\n": "");
 #ifdef USE_MANUAL_CALLSTACK
     call_stack.exit();
 #endif
@@ -801,7 +834,9 @@ ChirpData_func ChooseChirpData() {
     hires_timer timer;
     ChirpData_func chirp_data;
     int i,j,rv,k = sizeof(ChirpDataFuncs)/sizeof(CDtb);
-    double speed=1e+6,timing,accuracy;
+    double speed=1e+6,timing,accuracy,onetime;
+    std::vector<double> timings;
+    timings.reserve(1000);
     int NumDataPoints=1024*1024;
     int best;
     double best_timing, best_accuracy;
@@ -833,7 +868,7 @@ ChirpData_func ChooseChirpData() {
     }
     //JWS: Generate indata as the chirp of flat line (constant) data
     for (i=0;i<NumDataPoints;i++) {
-        double dd,cc,time,ang,recip_sample_rate=256.0/2.5e+6,chirp_rate=MinChirpStep*TESTCHIRPIND;
+        double dd,cc,time,ang,recip_sample_rate=1.0/swi.subband_sample_rate,chirp_rate=MinChirpStep*TESTCHIRPIND;
         // Notionally:
         //float c,d;
         //save[i][0] = 1.0f;
@@ -862,7 +897,7 @@ ChirpData_func ChooseChirpData() {
     for (i=0;i<k;i++) {
 #endif
             if (!(CPUCaps & ChirpDataFuncs[i].ba)) {
-                if (verbose)
+                if (verbose>1)
                     fprintf(stderr,"%32s not supported on CPU\n",
                                    ChirpDataFuncs[i].nom);
                 continue;
@@ -872,14 +907,16 @@ ChirpData_func ChooseChirpData() {
             if (CacheChirpCalc) {
                     // Give the cached functions something to on the first call.
                     FreeTrigArray();
-                    InitTrigArray(NumDataPoints, MinChirpStep,TESTCHIRPIND-1,2.5e+6/256.0);
+                    InitTrigArray(NumDataPoints, MinChirpStep,TESTCHIRPIND-1,swi.subband_sample_rate);
             }
             int ind=TESTCHIRPIND;
-            while ((j<100) && ((j<10) || (timing<(3*timer.resolution())))) {
+            while ((j<100) && ((j<20) || (timing<(10*timer.resolution())))) {
                 memset(outdata,0,NumDataPoints*sizeof(sah_complex));
                 timer.start();
-                rv=ChirpDataFuncs[i].func(indata,outdata,ind,MinChirpStep*ind,NumDataPoints,2.5e+6/256.0);
-                timing+=timer.stop();
+                rv=ChirpDataFuncs[i].func(indata,outdata,ind,MinChirpStep*ind,NumDataPoints,swi.subband_sample_rate);
+                onetime=timer.stop();
+                timing+=onetime;
+                timings.push_back(onetime);
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
                 if (rv) siglongjmp(jb,1);
 #else
@@ -894,7 +931,10 @@ ChirpData_func ChooseChirpData() {
                 j++;
             }
             if (rv) continue;
-            timing/=j;
+            std::sort(timings.begin(),timings.end());
+            timing=timings[timings.size()/2];
+            if (timing==0) timing=std::accumulate(timings.begin(),timings.end(),0.0)/timings.size();
+            timings.clear();
             accuracy=0;
             //JWS: indata is positive chirp of constant at TESTCHIRPIND, test was copied
             // at -TESTCHIRPIND so we check for deviation from flat
@@ -903,8 +943,8 @@ ChirpData_func ChooseChirpData() {
                 accuracy+=(test[j+1][1]-test[j][1])*(test[j+1][1]-test[j][1]);
             }
             accuracy=sqrt(accuracy)/1000; // milli whatevers
-            //if (verbose) fprintf(stderr,"%32s %8.6f %7g  test\n",ChirpDataFuncs[i].nom,timing,accuracy);
-            if (verbose) {
+            //if (verbose>1) fprintf(stderr,"%32s %8.6f %7g  test\n",ChirpDataFuncs[i].nom,timing,accuracy);
+            if (verbose>1) {
                 fprintf(stderr,"%32s %8.6f %7.5f  test\n",ChirpDataFuncs[i].nom,timing,accuracy);
                 fflush(stderr);
             }
@@ -917,7 +957,7 @@ ChirpData_func ChooseChirpData() {
             }
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
         } else {
-            if (verbose) {
+            if (verbose>1) {
                 fprintf(stderr,"%32s faulted\n",ChirpDataFuncs[i].nom);
                 fflush(stderr);
             }
@@ -936,7 +976,7 @@ ChirpData_func ChooseChirpData() {
                        ChirpDataFuncs[best].nom,
                        best_timing,
                        best_accuracy,
-                       verbose ? " choice\n": "");    
+                       (verbose>1) ? " choice\n": "");    
 #ifdef USE_MANUAL_CALLSTACK
     call_stack.exit();
 #endif
@@ -947,8 +987,8 @@ Transpose_func ChooseTranspose() {
 #ifdef USE_MANUAL_CALLSTACK
     call_stack.enter("ChooseTranspose()");
 #endif 
-    if (default_functions_flag) {
-      if (do_print)
+    if (default_functions_flag || !use_transposed_pot) {
+      if (do_print && use_transposed_pot)
         fprintf(stderr,"%32s (default)\n",TransposeFuncs[2].nom); //JWS: v_Transpose4 is the default
 #ifdef USE_MANUAL_CALLSTACK
       call_stack.exit();
@@ -958,7 +998,9 @@ Transpose_func ChooseTranspose() {
     hires_timer timer;
     Transpose_func transpose;
     int i,j,rv;
-    double speed=1e+6,timing,mintime,onetime,accuracy;
+    double speed=1e+6,timing,onetime,accuracy;
+    std::vector<double> timings;
+    timings.reserve(1000);
     int NumDataPoints=1024*1024;
     int best;
     double best_timing, best_accuracy;    
@@ -990,22 +1032,21 @@ Transpose_func ChooseTranspose() {
     for (i=0;(i*sizeof(TPtb))<sizeof(TransposeFuncs);i++) {
 #endif
             if (!(CPUCaps & TransposeFuncs[i].ba)) {
-                if (verbose)
+                if (verbose>1)
                     fprintf(stderr,"%32s not supported on CPU\n",
                                    TransposeFuncs[i].nom);
                 continue;
             }
             j=0;
             timing=0;
-            mintime=1e6;
             int ind=0;
-            while ((j<100) && ((j<10) || (timing<(3*timer.resolution())))) {
+            while ((j<100) && ((j<20) || (timing<(10*timer.resolution())))) {
                 memset(outdata,0,NumDataPoints*sizeof(float));
                 timer.start();
                 rv=TransposeFuncs[i].func(16384,64,indata,outdata);
                 onetime=timer.stop();
                 timing+=onetime;
-                if (onetime<mintime) mintime=onetime;
+                timings.push_back(onetime);
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
                 if (rv) siglongjmp(jb,1);
 #else
@@ -1014,8 +1055,10 @@ Transpose_func ChooseTranspose() {
                 j++;
             }
             if (rv) continue;
-            timing/=j;
-            timing = (timing+mintime)/2;
+            std::sort(timings.begin(),timings.end());
+            timing=timings[timings.size()/2];
+            if (timing==0) timing=std::accumulate(timings.begin(),timings.end(),0.0)/timings.size();
+            timings.clear();
             if (i==0) {
                 accuracy=0;
                 memcpy(save,outdata,NumDataPoints*sizeof(float));
@@ -1026,7 +1069,7 @@ Transpose_func ChooseTranspose() {
                 }
                 accuracy=sqrt(accuracy);
             }
-            if (verbose) {
+            if (verbose>1) {
                 fprintf(stderr,"%32s %8.6f %7.5f  test\n",TransposeFuncs[i].nom,timing,accuracy);
                 fflush(stderr);
             }
@@ -1040,7 +1083,7 @@ Transpose_func ChooseTranspose() {
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
         } else {
             // reinstall_sighandler();
-            if (verbose) {
+            if (verbose>1) {
                 fprintf(stderr,"%32s faulted\n",TransposeFuncs[i].nom);
                 fflush(stderr);
             }
@@ -1058,7 +1101,7 @@ Transpose_func ChooseTranspose() {
                         TransposeFuncs[best].nom,
                         best_timing,
                         best_accuracy,
-                        verbose ? " choice\n": "");    
+                        (verbose>1) ? " choice\n": "");    
 #ifdef USE_MANUAL_CALLSTACK
     call_stack.exit();
 #endif
@@ -1258,6 +1301,8 @@ int ChooseFoldSubs(ChirpFftPair_t * ChirpFftPairs, int num_cfft, int nsamples) {
   int i, iL, j, k, ndivs, NumPlans = 0, MaxPulsePoT = PoTInfo.PulseMax;
   double onetime, timing, best_timing, speed = 1e+6;
   double accuracy,  best_accuracy, errmax, dTmp = 1e+30;
+  std::vector<double> timings;
+  timings.reserve(1000);
   int best;
   int PoTLen, PulsePoTLen, Overlap, FFTtbl[32][5] = {0, 0, 0, 0, 0};
   double NumSamples = nsamples;
@@ -1367,7 +1412,7 @@ int ChooseFoldSubs(ChirpFftPair_t * ChirpFftPairs, int num_cfft, int nsamples) {
   for (i = 0; (i * sizeof(FolSub)) < sizeof(FoldSubs); i++) {
 #endif
       if (!(CPUCaps & FoldSubs[i].ba)) {
-          if (verbose)
+          if (verbose>1)
               fprintf(stderr,"%24s folding not supported on CPU\n",
                              FoldSubs[i].fsp->name);
           continue;
@@ -1377,7 +1422,7 @@ int ChooseFoldSubs(ChirpFftPair_t * ChirpFftPairs, int num_cfft, int nsamples) {
       CopyFoldSet(&TestFoldSet, FoldSubs[i].fsp);
       int n = planFoldTest(PlanBuf, outdata, FFTtbl);
 //    if (!i) fprintf(stderr, "Actual Preplans = %d\n", n);
-      while ((j < 100) && ((j < 10) || ((j * timing) < (3 * timer.resolution())))) {
+      while ((j < 100) && ((j < 10) || ((timing) < (10 * timer.resolution())))) {
         memset(outdata, 0, MaxPulsePoT * sizeof(float)); 
         memset(maxdata, 0, NumPlans * sizeof(float)); 
         maxdata[0] = -1.234f;
@@ -1386,8 +1431,8 @@ int ChooseFoldSubs(ChirpFftPair_t * ChirpFftPairs, int num_cfft, int nsamples) {
           maxdata[k] = PlanBuf[k].fun_ptr(SrcSel, &PlanBuf[k]);
         }
         onetime = timer.stop();
-        if (j) timing = std::min(onetime, timing);
-        else timing = onetime;
+        timing+=onetime;
+        timings.push_back(onetime);
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
         if (maxdata[0] < 0) siglongjmp(jb,1);
 #else
@@ -1395,6 +1440,10 @@ int ChooseFoldSubs(ChirpFftPair_t * ChirpFftPairs, int num_cfft, int nsamples) {
 #endif
         j++;
       }
+      std::sort(timings.begin(),timings.end());
+      timing=timings[timings.size()/2];
+      if (timing==0) timing=std::accumulate(timings.begin(),timings.end(),0.0)/timings.size();
+      timings.clear();
       accuracy = 0;
       errmax = 0;
       if (i == 0) {
@@ -1410,7 +1459,7 @@ int ChooseFoldSubs(ChirpFftPair_t * ChirpFftPairs, int num_cfft, int nsamples) {
         }
       }
       accuracy /= NumPlans;
-      if (verbose) {
+      if (verbose>1) {
         fprintf(stderr, "%24s folding %8.6f %7.5f  test\n", FoldSubs[i].fsp->name, timing, accuracy);
         fflush(stderr);
       }
@@ -1423,7 +1472,7 @@ int ChooseFoldSubs(ChirpFftPair_t * ChirpFftPairs, int num_cfft, int nsamples) {
 #if !defined(USE_ASMLIB) && !defined(__APPLE_CC__)
     } else {
       // reinstall_sighandler();
-      if (verbose) {
+      if (verbose>1) {
         fprintf(stderr, "%24s folding faulted\n", FoldSubs[i].fsp->name);
         fflush(stderr);
       }
@@ -1443,7 +1492,7 @@ int ChooseFoldSubs(ChirpFftPair_t * ChirpFftPairs, int num_cfft, int nsamples) {
                     FoldSubs[best].fsp->name,
                     best_timing,
                     best_accuracy,
-                    verbose ? " choice\n": "");  
+                    (verbose>1) ? " choice\n": "");  
   CopyFoldSet(&Foldmain, FoldSubs[best].fsp);
 #ifdef USE_MANUAL_CALLSTACK
   call_stack.exit();
@@ -1465,7 +1514,7 @@ void ChooseFunctions(BaseLineSmooth_func *baseline_smooth,
     call_stack.enter("ChooseFunctions()");
 #endif 
     do_print=print_choices;
-    if (verbose) do_print = true;
+    if (verbose>1) do_print = true;
     if (TestBoincSignalHandling()) {
         SetCapabilities();
         hires_timer durtimer;
@@ -1540,7 +1589,7 @@ void ChooseFunctions(BaseLineSmooth_func *baseline_smooth,
                  CopyFoldSet(&Foldmain, &vfpFoldMain);
                  found_folding=true;
                  if (do_print) fprintf(stderr,"%32s (CPU Caps)\n",
-                                       "oft VFP folding");
+                                       "opt VFP folding");
              } else {
 #endif
                  CopyFoldSet(&Foldmain, &swifold);
@@ -1551,12 +1600,14 @@ void ChooseFunctions(BaseLineSmooth_func *baseline_smooth,
              }
 #endif
              TestDur+=durtimer.stop();
-             if (verbose)
+             if (verbose>1)
                  fprintf(stderr,"%32s %8.2f seconds\n\n","Test duration",TestDur);
              if (do_print) {
                  fflush(stderr);
              }
+#ifdef USE_MANUAL_CALLSTACK
              call_stack.exit();
+#endif
              return;
         }
 #endif
@@ -1598,7 +1649,7 @@ void ChooseFunctions(BaseLineSmooth_func *baseline_smooth,
         }
         fflush(stderr);
         TestDur+=durtimer.stop();
-        if (verbose)
+        if (verbose>1)
             fprintf(stderr,"%32s %8.2f seconds\n\n","Test duration",TestDur);
     }
 
diff --git a/client/vector/analyzeFuncs_vector.h b/client/vector/analyzeFuncs_vector.h
index 0d06e1b..c068d2a 100644
--- a/client/vector/analyzeFuncs_vector.h
+++ b/client/vector/analyzeFuncs_vector.h
@@ -252,6 +252,9 @@ extern int v_vpfTranspose8x4ntw(int i, int j, float *in, float *out);
 #if (defined(__arm__) && defined(__VFP_FP__) && !defined(__SOFTFP__))
 extern int v_vfpTranspose2(int i, int j, float *in, float *out);
 #endif
+#ifdef USE_FFTWF
+extern int fftwf_transpose(int i, int j, float *in, float *out);
+#endif
 
 
 #if defined(__i386__) || defined(__x86_64__) || defined(USE_SSE)
diff --git a/client/vector/analyzeFuncs_vfp_aux.cpp b/client/vector/analyzeFuncs_vfp_aux.cpp
index 531ce68..a3e6913 100644
--- a/client/vector/analyzeFuncs_vfp_aux.cpp
+++ b/client/vector/analyzeFuncs_vfp_aux.cpp
@@ -49,18 +49,6 @@
 #include "pulsefind.h"
 
 
-// ARM prefetch
-
-inline void pld(void *arg1,const int arg2=0) {
-    __asm__ __volatile__ (
-      "pld [%0,%1]\n"
-      : 
-      : "r" (arg1), "Jr" (arg2)
-    );
-}
-
-
-    
 template <int x>
 inline void v_pfsubTranspose(float *in, float *out, int xline, int yline) {
     // Transpose an X by X subsection of a XLINE by YLINE matrix into the
diff --git a/client/vector/analyzeFuncs_x86_64.cpp b/client/vector/analyzeFuncs_x86_64.cpp
index e2006a4..1eaafd6 100644
--- a/client/vector/analyzeFuncs_x86_64.cpp
+++ b/client/vector/analyzeFuncs_x86_64.cpp
@@ -17,12 +17,12 @@
 // In addition, as a special exception, the Regents of the University of
 // California give permission to link the code of this program with libraries
 // that provide specific optimized fast Fourier transform (FFT) functions and
-// distribute a linked executable.  You must obey the GNU General Public 
+// distribute a linked executable.  You must obey the GNU General Public
 // License in all respects for all of the code used other than the FFT library
 // itself.  Any modification required to support these libraries must be
-// distributed in source code form.  If you modify this file, you may extend 
-// this exception to your version of the file, but you are not obligated to 
-// do so. If you do not wish to do so, delete this exception statement from 
+// distributed in source code form.  If you modify this file, you may extend
+// this exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to do so, delete this exception statement from
 // your version.
 
 // AMD optimizations by Evandro Menezes
@@ -60,7 +60,8 @@ int v_vChirpData_x86_64(
 ) {
 #ifdef USE_MANUAL_CALLSTACK
     call_stack.enter("v_vChirpData_x86_64()");
-#endif 
+#endif
+    double recsqtw_Sample_rate = (double)(1.0/(2.0*(sample_rate*sample_rate)));
     static const int as [4]  __attribute__((aligned(16)))= {INT_MIN, 0, INT_MIN, 0} ; // {-, +, -, +}
     char *cblock = (char *)alloca(11*16);
     cblock+=(16-((ssize_t)cblock % 16));
@@ -80,15 +81,17 @@ int v_vChirpData_x86_64(
     zz = _mm_setzero_ps ();
     int i, j;
     // float c, d, real, imag;
-    float time;
-    float ang;
+    //float time; // using float causes too low precision
+    double time;
+    //float ang; // using float causes too low precision
+    double ang;
 
     double aC []  __attribute__((aligned(16))) = {0, 0};
     double aD []  __attribute__((aligned(16))) = {0, 0} ;
 
-    float chirpInvariant = (float)(0.5*chirp_rate/(sample_rate*sample_rate));
-    
-    if (chirp_rate == 0.0) {
+    //float chirpInvariant = (float)(0.5*chirp_rate/(sample_rate*sample_rate));
+    double chirpInvariant = chirp_rate*recsqtw_Sample_rate; //using float causes too low precision
+    if (chirp_rate == 0) {
         memcpy(fp_ChirpDataArray,
        fp_DataArray,
        (int)ul_NumDataPoints * 2 * sizeof(float)
@@ -99,27 +102,27 @@ int v_vChirpData_x86_64(
                 // _mm_prefetch (fp_DataArray      + i + 32, _MM_HINT_T0);
                 _mm_prefetch ((char *) (fp_ChirpDataArray + i) + 384, _MM_HINT_T0);
 
-                time = (float)j*j;
-		        ang = time*chirpInvariant;
-                ang -= floor(ang);
-		        ang *= (float)(M_PI*2);
-#ifndef HAVE_SINCOS
+                time = (double)j*j;
+                ang = time*chirpInvariant;
+                ang -= std::floor(ang);
+                ang *= M_PI*2.0;
+//#ifndef HAVE_SINCOS
                 aC [0] = cos (ang);
                 aD [0] = sin (ang);
-#else
+/*#else // using sincos causes too low precision
                 sincos (ang, aD + 0, aC + 0);
-#endif
+#endif */
 
-                time = (float)(j + 1)*(j + 1);
-		        ang = chirpInvariant*time;
-                ang -= floor(ang);
-		        ang *= (float)(M_PI*2);
-#ifndef HAVE_SINCOS
+                time = (double)(j + 1)*(j + 1);
+                ang = chirpInvariant*time;
+                ang -= std::floor(ang);
+                ang *= M_PI*2.0;
+//#ifndef HAVE_SINCOS
                 aC [1] = cos (ang);
                 aD [1] = sin (ang);
-#else
+/*#else // using sincos causes too low precision
                 sincos (ang, aD + 1, aC + 1);
-#endif
+#endif */
 
                 CC = _mm_loadu_pd (aC);
                 DD = _mm_loadu_pd (aD);
@@ -150,16 +153,16 @@ int v_vChirpData_x86_64(
                 // _mm_prefetch (fp_DataArray      + i + 16, _MM_HINT_T0);
                 _mm_prefetch ((char *) (fp_ChirpDataArray + i) + 384, _MM_HINT_T0);
 
-                time = (float)j*j;
-		        ang = chirpInvariant*time;
-                ang -= floor(ang);
-		        ang *= (float)(M_PI*2);
-#ifndef HAVE_SINCOS
+                time = (double)j*j;
+                ang = chirpInvariant*time;
+                ang -= std::floor(ang);
+                ang *= M_PI*2.0;
+//#ifndef HAVE_SINCOS
                 aC [0] = cos (ang);
                 aC [1] = sin (ang);
-#else
+/*#else // using sincos causes too low precision
                 sincos (ang, aC + 0, aC + 1);
-#endif
+#endif */
 
                 CC = _mm_loadu_pd (aC);
 
@@ -186,8 +189,8 @@ int v_vChirpData_x86_64(
     }
 #ifdef USE_MANUAL_CALLSTACK
     call_stack.exit();
-#endif 
+#endif
     return 0;
 }
-#endif  
+#endif
 
diff --git a/client/vector/fp_arm.h b/client/vector/fp_arm.h
index a4197c3..9a7ba95 100644
--- a/client/vector/fp_arm.h
+++ b/client/vector/fp_arm.h
@@ -36,7 +36,7 @@
 // work so modified without permission of the authors of those packages.
 //
 
-#if defined(__arm__) && !defined(_RC_CHOP)
+#if defined(__arm__) 
 #include <signal.h>
 #include <setjmp.h>
 #include "s_util.h"
@@ -120,6 +120,19 @@ inline static unsigned int restorefp() {
     return save_cw;
 }
 
+
+// ARM prefetch
+
+inline void pld(void *arg1,const int arg2=0) {
+    __asm__ __volatile__ (
+      "pld [%0,%1]\n"
+      : 
+      : "r" (arg1), "Jr" (arg2)
+    );
+}
+
+
+
 #if 0
 static const uint64_t arm_TWO_TO_52(0x4330000000000000);
 static const uint64_t arm_SIGN_BIT(0x8000000000000000);
diff --git a/client/win-sah_config.h b/client/win-sah_config.h
index 9e844d6..efb121f 100644
--- a/client/win-sah_config.h
+++ b/client/win-sah_config.h
@@ -30,6 +30,9 @@
 #ifndef _SAH_WIN_CONFIG_H_
 #define _SAH_WIN_CONFIG_H_
 
+#ifdef __MINGW32__
+#include <stdlib.h>
+#endif
 #include "boinc_win.h"
 
 
@@ -47,6 +50,7 @@
 #define HAVE_IMMINTRIN_H 1
 #define HAVE_PMMINTRIN_H 1
 #endif
+#ifndef AP_CLIENT
 #define HAVE_XMMINTRIN_H 1
 #define HAVE_EMMINTRIN_H 1
 #define USE_INTRINSICS 1
@@ -54,20 +58,24 @@
 #define USE_SSE2 1
 #define USE_SSE3 1
 #define USE_AVX  1
-
+#endif
 /* Define to 1 if you have the _aligned_malloc() function */
 #ifdef _MSC_VER
+#if _MSC_VER == 1500 //R: VS2008 unable to build AVX
+	#undef USE_AVX 
+#endif
 #define HAVE__ALIGNED_MALLOC 1
+#define HAVE__ALIGNED_FREE 1
 #endif
 
 /* Define to the typecast required for arg 2 of _mm256_maskstore_ps() */
 // TODO: Simply this mess.  Should only need 1 #if and an #else
 #if defined(_MSC_VER)
-#define AVX_MASKSTORE_TYPECAST(x) static_cast<__m256i>(x)
+#define AVX_MASKSTORE_TYPECAST(x) (*reinterpret_cast<__m256i *>(&x))
 #elif (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5) \
    || ((__GNUC__ == 4) && (__GNUC_MINOR__ == 5) && (__GNUC_PATCHLEVEL__ > 2)) \
    || ((__GNUC__ == 4) && (__GNUC_MINOR__ == 4) && (__GNUC_PATCHLEVEL__ > 5)))
-#define AVX_MASKSTORE_TYPECAST(x) static_cast<__m256i>(x)
+#define AVX_MASKSTORE_TYPECAST(x) *reinterpret_cast<__m256i *>(&x)
 #elif defined(__GNUC__)
 #define AVX_MASKSTORE_TYPECAST(x) static_cast<__m256>(x)
 #else
@@ -80,6 +88,19 @@
 #undef USE_AVX
 #undef HAVE_IMMINTRIN_H
 #endif
+
+#if defined(__GNUC__)
+#define HAVE_DECL___BUILTIN_ALLOCA 1
+#define HAVE_DECL___BUILTIN_CLZ 1
+#define HAVE_DECL___BUILTIN_FFS 1
+#define HAVE_DECL___BUILTIN_POPCOUNT 1
+#define HAVE_DECL___BUILTIN_PREFETCH 1
+#define HAVE___BUILTIN_ALLOCA 1
+#define HAVE___BUILTIN_CLZ 1
+#define HAVE___BUILTIN_FFS 1
+#define HAVE___BUILTIN_POPCOUNT 1
+#define HAVE___BUILTIN_PREFETCH 1
+#endif
     
 /* Define to 1 if you have the alloca() function */
 #define HAVE_ALLOCA 1
@@ -114,10 +135,13 @@
 //#define HAVE_FORK 1
 
 /* Define to 1 if you have the `getcwd' function. */
-#define HAVE_GETCWD 1
+// #define HAVE_GETCWD 1
 
 /* Define to 1 if you have the <GLUT/glut.h> header file. */
-#define HAVE_GLUT_GLUT_H 1
+//#define HAVE_GLUT_GLUT_H 1
+
+/* Define to 1 if you have the <GL/freeglut.h> header file. */
+#define HAVE_GL_FREEGLUT_H 1
 
 /* Define to 1 if you have the <glut.h> header file. */
 #define HAVE_GLUT_H 1
@@ -401,14 +425,18 @@
                         QUOTEME(__GNUC_MINOR__) "."\
                         QUOTEME(__GNUC_PATCHLEVEL__)
 #elif defined(_MSC_VER)
-#define COMPILER_STRING "Visual Studio 2005/Microsoft Visual C++ 8"
+#if _MSC_VER == 1500
+	#define COMPILER_STRING "Visual Studio 2008/Microsoft Visual C++ 9"
+#else
+	#define COMPILER_STRING "Visual Studio 2010/Microsoft Visual C++ 10"
+#endif
 #else 
 #define COMPILER_STRING "Unknown Compiler"
 #endif
 #endif
 
 #ifndef CUSTOM_STRING
-#define CUSTOM_STRING "setiathome_v7 "FILE_VERSION" "COMPILER_STRING
+#define CUSTOM_STRING "setiathome_v8 "FILE_VERSION" "COMPILER_STRING
 #endif
 
 /* The size of a `long double', as computed by sizeof. */
@@ -438,6 +466,12 @@
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */
 
+#ifdef __MINGW32__
+#undef HAVE_SIGACTION
+#undef HAVE_STRLCPY
+#undef HAVE_STRLCAT
+#endif
+
 /* Define as `__inline' if that's what the C compiler calls it, or to nothing
    if it is not supported. */
 #ifdef _MSC_VER
diff --git a/client/worker.cpp b/client/worker.cpp
index f610613..7b16c1f 100644
--- a/client/worker.cpp
+++ b/client/worker.cpp
@@ -64,7 +64,7 @@
 
 using std::string;
 
-bool verbose;
+int verbose=1;
 
 // this gets called first on all platforms
 int common_init() {
diff --git a/client/worker.h b/client/worker.h
index 74fa489..f2a28ee 100644
--- a/client/worker.h
+++ b/client/worker.h
@@ -29,7 +29,6 @@
 
 extern int common_init();
 extern void worker();
-
 extern char * cfft_file;
 extern char debug_cfft_file[];
 
diff --git a/client/x86_64_graphics_link b/client/x86_64_graphics_link
new file mode 100644
index 0000000..020ecd6
--- /dev/null
+++ b/client/x86_64_graphics_link
@@ -0,0 +1 @@
+ g++ -g -Wall -I/usr/local/include -static-libgcc -g -Wall -I/usr/local/include -I/usr/include -I/usr/include/openssl -DHAVE_CONFIG_H -DTEXT_UI -DNDEBUG -DCLIENT -I../db -I../client -I../client/win_build -I/home/korpela/build/x86_64-linux/boinc -I/home/korpela/build/x86_64-linux/boinc/api -I/home/korpela/build/x86_64-linux/boinc/lib -I/home/korpela/build/x86_64-linux/boinc/sched -I/home/korpela/build/x86_64-linux/boinc/db -I/home/korpela/build/x86_64-linux/boinc/clientgui/mac -pthread -m [...]
diff --git a/configure.ac b/configure.ac
index f8c4a89..56073de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,12 +4,12 @@
 
 
 AC_PREREQ(2.57)
-AC_INIT(setiathome_v7, 7.28, korpela at ssl.berkeley.edu)
+AC_INIT(setiathome_v8, 8.00, korpela at ssl.berkeley.edu)
 AC_CONFIG_MACRO_DIR([m4])
 svnrev="`svn info | grep Revision:`"
 
 if test -n "${svnrev}" ; then
-  AC_REVISION("${svnrev}") 
+  AC_REVISION("${svnrev}")
   AC_DEFINE_UNQUOTED(SVN_REV,"${svnrev}",
     [Define to be the subversion revision number])
 else
@@ -18,6 +18,9 @@ else
     [Define to be the subversion revision number])
 fi
 
+echo "WARNING! Changes have been made which are not compatible with SETI at home"
+echo "v7.  Do not use this version with the projects until v8 is released"
+
 AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE(dist-zip)
 AC_CONFIG_SRCDIR([client/analyze.h])
@@ -34,10 +37,10 @@ fi
 
 
 # Make sure we use the same initial CFLAGS and CXXFLAGS unless otherwise told.
-if test -z "${CXXFLAGS}" 
+if test -z "${CXXFLAGS}"
 then
   CXXFLAGS="${CFLAGS}"
-elif test -z "${CFLAGS}" 
+elif test -z "${CFLAGS}"
 then
   CFLAGS="${CXXFLAGS}"
 fi
@@ -55,16 +58,16 @@ if test -z "`echo ${LDFLAGS} | grep ${tmplib}`" ; then
   LDFLAGS="${LDFLAGS} -L${tmplib}"
 fi
 
-AC_ARG_ENABLE(intrinsics, 
+AC_ARG_ENABLE(intrinsics,
     AS_HELP_STRING([--disable-intrinsics],
                    [disable use of intrinsics in SIMD code]))
-		   
+
 
 if test "x$enable_intrinsics" != xno ; then
   enable_intrinsics=yes
 fi
-  
-AC_ARG_ENABLE(graphics, 
+
+AC_ARG_ENABLE(graphics,
     AC_HELP_STRING([--disable-graphics],
                    [disable building the client graphics]))
 
@@ -81,27 +84,27 @@ AC_ARG_ENABLE(tests,
     [],
     [enable_tests=yes])
 
-AC_ARG_ENABLE(server, 
+AC_ARG_ENABLE(server,
     AC_HELP_STRING([--disable-server],
                    [disable building the seti at home server components]),
     [],
     [enable_server=yes])
 
 
-AC_ARG_ENABLE(client, 
+AC_ARG_ENABLE(client,
     AC_HELP_STRING([--disable-client],
                    [disable building the client]),
     [],
     [enable_client=yes])
 
-AC_ARG_ENABLE(static-client, 
+AC_ARG_ENABLE(static-client,
     AC_HELP_STRING([--disable-static-client],
                    [allow dynamic libraries to be used in the client]),
     [enable_static_client=${enableval}],
     [enable_static_client=yes])
 
 m4_divert_once([HELP_ENABLE],
-  AC_HELP_STRING([], [Default: --enable-server --enable-client: 
+  AC_HELP_STRING([], [Default: --enable-server --enable-client:
                       builds both server and client]))
 
 if test "${enable_server}" = yes ; then
@@ -183,7 +186,16 @@ AC_SUBST(SED)
 AC_C_BIGENDIAN
 AX_C_FLOAT_WORDS_BIGENDIAN
 
-SAH_OPTION_BITNESS 
+SAH_OPTION_BITNESS
+
+SAH_REQUIRES([boinc],[SAH_CHECK_BOINC],["${no_boinc}" = yes],
+[
+ERROR: trying to build the seti_boinc client or server but BOINC was not
+found.
+You can get boinc at http://boinc.ssl.berkeley.edu/
+],
+[exit 1])
+AC_SUBST([BOINCDIR])
 
 dnl Determine the BOINC platform given the target arch-platform-os.
 BOINC_PLATFORM
@@ -226,7 +238,7 @@ dnl    [APP_LIBS="-lcorkscrew ${APP_LIBS}"])
 
 AC_CHECK_LIB([m], [sin],[
     AC_DEFINE([HAVE_LIBM],[1],[Define to 1 if you have the math library])
-    APP_LIBS="-lm ${APP_LIBS}" 
+    APP_LIBS="-lm ${APP_LIBS}"
 ])
 SAH_CHECK_MATH_FUNCS([sqrt floor sinf cosf sincos sincosf atanf isnan _isnan __isnan __isnanf _isnanf isnanf])
 AC_CHECK_LIB([fftw3f], [fftwf_plan_dft_1d], [
@@ -247,7 +259,7 @@ AC_CHECK_LIB([cpufeatures], [android_getCpuFeatures], [
 ],
 [],
 [-lm])
-AC_ARG_ENABLE(neon, 
+AC_ARG_ENABLE(neon,
     AC_HELP_STRING([--disable-neon],
                    [Disable neon instruction set on ARM devices]),
     [enable_neon=${enableval}],
@@ -288,7 +300,7 @@ if test "$enable_graphics" = yes ; then
 ================================================================================
 WARNING: GL/GLU/GLUT not found.
 
-The GL, GLU, and GLUT libraries are required in order to build the graphical 
+The GL, GLU, and GLUT libraries are required in order to build the graphical
 parts of the BOINC application API library.
 
 ==> only building non-graphical parts of the BOINC API Library for now.
@@ -300,7 +312,7 @@ else
      SAH_GRX_INCLUDES
      GRAPHICS_CFLAGS="${GRX_CFLAGS} ${GL_CFLAGS} ${GLU_CFLAGS} ${GLUT_CFLAGS}"
      GRAPHICS_LIBS="${GL_LIBS} ${GLU_LIBS} ${GLUT_LIBS} ${GRX_LIBS} -ljpeg"
-     
+
 case ${target} in
         powerpc-apple*)       GRAPHICS_LIBS="${GRAPHICS_LIBS} -framework AppKit -framework CoreServices"
         ;;
@@ -320,25 +332,25 @@ AC_CACHE_SAVE
 
 fi
 
-dnl SAH_CHECK_LIB([c],[atexit], 
+dnl SAH_CHECK_LIB([c],[atexit],
 dnl     AC_DEFINE([HAVE_LIBC],[1],[Define to 1 if you have the c library]))
 dnl SAH_CHECK_LIB([pthread],[pthread_join],
 dnl     AC_DEFINE([HAVE_LIBPTHREAD],[1],[Define to 1 if you have the pthread library]))
-dnl AC_CHECK_LIB([gcc],[sscanf], 
+dnl AC_CHECK_LIB([gcc],[sscanf],
 dnl     AC_DEFINE([HAVE_LIBGCC],[1],[Define to 1 if you have the gcc library]))
-dnl SAH_CHECK_LIB([gcc_eh],[_Unwind_Resume], 
+dnl SAH_CHECK_LIB([gcc_eh],[_Unwind_Resume],
 dnl     AC_DEFINE([HAVE_LIBGCC_EH],[1],[Define to 1 if you have the gcc_eh library]))
-dnl SAH_CHECK_LIB([gcc_s],[sscanf], 
+dnl SAH_CHECK_LIB([gcc_s],[sscanf],
 dnl     AC_DEFINE([HAVE_LIBGCC_S],[1],[Define to 1 if you have the gcc_s library]))
 dnl AC_CHECK_LIB([stdc++],[sscanf],
 dnl     AC_DEFINE([HAVE_LIBSTDC__],[1],[Define to 1 if you have the stdc++ library]))
-dnl AC_CHECK_LIB([z], [uncompress], 
+dnl AC_CHECK_LIB([z], [uncompress],
 dnl     AC_DEFINE([HAVE_LIBZ],[1],[Define to 1 if you have the z library]))
-dnl AC_CHECK_LIB([socket], [bind], 
+dnl AC_CHECK_LIB([socket], [bind],
 dnl     AC_DEFINE([HAVE_LIBSOCKET],[1],[Define to 1 if you have the socket library]))
-dnl AC_CHECK_LIB([rt], [sched_get_priority_min], 
+dnl AC_CHECK_LIB([rt], [sched_get_priority_min],
 dnl     AC_DEFINE([HAVE_LIBRT],[1],[Define to 1 if you have the rt library]))
-dnl AC_CHECK_LIB([nsl], [gethostbyname], 
+dnl AC_CHECK_LIB([nsl], [gethostbyname],
 dnl     AC_DEFINE([HAVE_LIBNSL],[1],[Define to 1 if you have the nsl library]))
 dnl AC_CHECK_LIB([elf], [elf_hash],
 dnl     AC_DEFINE([HAVE_LIBELF],[1],[Define to 1 if you have the elf library]))
@@ -347,13 +359,18 @@ dnl     AC_DEFINE([HAVE_LIBAIO],[1],[Define to 1 if you have the aio library]))
 CHECK_SSL
 AC_CHECK_LIB([ssl], [fopen],
     [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} -L${SSLDIR}/lib ${sah_lib_last}"])
-AC_CHECK_LIB([crypto], [RSA_new], 
+AC_CHECK_LIB([crypto], [RSA_new],
     [BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} -L${SSLDIR}/lib ${sah_lib_last}"])
- 
+
 dnl AC_CHECK_LIB([dl], [dlopen],
 dnl   AC_DEFINE([HAVE_LIBDL],[1],[Define to 1 if you have the dl library]))
 AC_LANG(C++)
 
+case ${target} in
+        *-apple-darwin*)       CLIENT_EXTRA_LIBS="${CLIENT_EXTRA_LIBS} -framework Accelerate -framework CoreServices"
+        ;;
+esac
+
 
 if test "${ac_cv_cxx_compiler_gnu}" = "yes" ; then
   gcc_version_string="`${CXX} --version | head -1`"
@@ -366,14 +383,7 @@ fi
 fi
 fi
 
-SAH_REQUIRES([boinc],[SAH_CHECK_BOINC],["${no_boinc}" = yes],
-[
-ERROR: trying to build the seti_boinc client or server but BOINC was not
-found.
 
-You can get boinc at http://boinc.ssl.berkeley.edu/
-],
-[exit 1])
 
 SAH_SERVER_REQUIRES([mysql],[SAH_CHECK_MYSQL],["${no_mysql}" = yes])
 SAH_SERVER_REQUIRES([informix],[SAH_CHECK_INFORMIX],["${no_informix}" = yes])
@@ -415,9 +425,13 @@ AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_STRUCT_ST_BLOCKS
 AC_STRUCT_TM
+AC_CHECK_SIZEOF([short])
+AC_CHECK_SIZEOF([int])
 AC_CHECK_SIZEOF([long int])
+AC_CHECK_SIZEOF([float])
+AC_CHECK_SIZEOF([double])
 AC_CHECK_SIZEOF([long double])
-AC_CHECK_TYPES([long long,_int64,int64_t,bool,_int32,int32_t, hrtime_t, uint_fast64_t, uint64_t, _uint64, u_int64_t, ptrdiff_t, ssize_t, off64_t])
+AC_CHECK_TYPES([long long,_int64,int64_t,bool,_int32, _uint32, int32_t, uint32_t, hrtime_t, uint_fast64_t, uint64_t, _uint64, u_int64_t, ptrdiff_t, ssize_t, off64_t])
 AC_CHECK_TYPES([sigjmp_buf, jmp_buf], [], [], [[#ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
@@ -493,13 +507,13 @@ AC_CHECK_TYPES([__m256,_m256,__m256d,_m256d,__m256i,_m256i],[],[],[[#ifdef HAVE_
 #endif
 #define __AVX__ 1
 #if defined(HAVE_IMMINTRIN_H)
-#include <immintrin.h> 
+#include <immintrin.h>
 #elif defined(HAVE_AVXINTRIN_H)
-#include <avxintrin.h> 
+#include <avxintrin.h>
 #elif defined(HAVE_X86INTRIN_H)
-#include <x86intrin.h> 
+#include <x86intrin.h>
 #elif defined(HAVE_INTRIN_H)
-#include <intrin.h> 
+#include <intrin.h>
 #endif
 ]])
 CXXFLAGS="${save_cxxflags}"
@@ -517,7 +531,31 @@ if test "${ac_cv_func_alloca_works}" = "yes" ; then
 fi
 AC_FUNC_STAT
 AC_FUNC_STRFTIME
-AC_CHECK_FUNCS([ _aligned_malloc alloca _alloca __builtin_alloca posix_memalign memalign atexit exit _exit getcwd memset munmap putenv strchr strstr strcasestr atoll dlopen gethrtime mach_absolute_time get_cyclecount clock_gettime nanotime microtime gettimeofday sqrt floor sinf cosf sincos sincosf atanf isnan _isnan __isnan isnanf _isnanf __isnanf siglongjmp sigsetjmp sigaction sysv_signal bsd_signal ])
+AC_CHECK_DECLS([__builtin_alloca,__builtin_popcount,__builtin_prefetch,__builtin_clz,__builtin_ffs,__builtin_isnan],
+   [],[],[[
+#include <stdio.h>
+#include <stdlib.h>
+]])
+if test "${ac_cv_have_decl___builtin_alloca}" = "yes" ; then
+  ac_cv_func___builtin_alloca="yes"
+fi
+if test "${ac_cv_have_decl___builtin_popcount}" = "yes" ; then
+  ac_cv_func___builtin_popcount="yes"
+fi
+if test "${ac_cv_have_decl___builtin_prefetch}" = "yes" ; then
+  ac_cv_func___builtin_prefetch="yes"
+fi
+if test "${ac_cv_have_decl___builtin_clz}" = "yes" ; then
+  ac_cv_func___builtin_clz="yes"
+fi
+if test "${ac_cv_have_decl___builtin_ffs}" = "yes" ; then
+  ac_cv_func___builtin_ffs="yes"
+fi
+if test "${ac_cv_have_decl___builtin_isnan}" = "yes" ; then
+  ac_cv_func___builtin_isnan="yes"
+fi
+
+AC_CHECK_FUNCS([ _aligned_malloc alloca _alloca __builtin_alloca __builtin_popcount __builtin_prefetch __builtin_clz __builtin_ffs posix_memalign memalign atexit exit _exit getcwd memset munmap putenv strchr strstr strcasestr atoll dlopen gethrtime mach_absolute_time get_cyclecount clock_gettime nanotime microtime gettimeofday sqrt floor sinf cosf sincos sincosf atanf isnan _isnan __isnan __builtin_isnan isnanf _isnanf __isnanf siglongjmp sigsetjmp sigaction sysv_signal bsd_signal ])
 SAH_CHECK_NAMESPACES
 AH_TEMPLATE([HAVE_STD_MIN],[Define to 1 if min is in namespace std::])
 AH_TEMPLATE([HAVE_STD_MAX],[Define to 1 if max is in namespace std::])
@@ -533,8 +571,8 @@ AM_CONDITIONAL(ENABLE_SERVER, [test "${enable_server}" = yes])
 AM_CONDITIONAL(ENABLE_CLIENT, [test "${enable_client}" = yes])
 AM_CONDITIONAL(ENABLE_GUI, [test "${enable_graphics}" = yes])
 AM_CONDITIONAL(LINUX, [test -n "`echo ${target} | grep linux`"])
-AM_CONDITIONAL(I386, [test -n "`echo ${target} | grep i.86`"])
-AM_CONDITIONAL(X86_64, [test -n "`echo ${target} | $EGREP 'x86_64|amd64'`"])
+AM_CONDITIONAL(I386, [test -n "`echo ${target} | $EGREP 'i.86|x86_64|amd64'`" -a $COMPILER_MODEL_BITS -eq 32])
+AM_CONDITIONAL(X86_64, [test -n "`echo ${target} | $EGREP 'i.86|x86_64|amd64'`" -a $COMPILER_MODEL_BITS -eq 64 ])
 AM_CONDITIONAL(PPC, [test -n "`echo ${target} | grep 'powerpc'`" -o -n "`echo ${target} | grep 'ppc'`" ])
 AM_CONDITIONAL(AVX, [test "x${have_avx}" = "xyes"])
 if test "x${avx_type}" != "x" ; then
@@ -600,7 +638,7 @@ AH_TOP([
 ])
 
 
-AH_BOTTOM([ 
+AH_BOTTOM([
 
 /* Define USE_NAMESPACES if you may access more than one database from the
  * same program
@@ -628,13 +666,17 @@ AH_BOTTOM([
 #endif
 ])
 
+AC_SUBST([CLIENT_EXTRA_LIBS])
+
 AC_CONFIG_FILES([Makefile
+                 glut/Makefile
+                 image_libs/Makefile
                  jpeglib/Makefile
                  client/Makefile
-		 tools/Makefile
+                 tools/Makefile
                  db/Makefile
                  db/tools/Makefile
-		 db/schema_to_class
+                 db/schema_to_class
                  assimilator/Makefile
                  validate/Makefile
                  splitter_pfb/Makefile
diff --git a/db/schema_master.cpp b/db/schema_master.cpp
index 2c97895..ac66d8c 100644
--- a/db/schema_master.cpp
+++ b/db/schema_master.cpp
@@ -31,15317 +31,15201 @@ int db_is_open;
 template <> const char * const db_type<coordinate_t>::type_name="coordinate_t";
 template <> const char * db_type<coordinate_t>::_search_tag=type_name;
 template <> const int db_type<coordinate_t>::_nfields=3;
-template <> const char * const db_type<coordinate_t>::column_names[3]= {"time","ra","dec"};
+template <> const char * const db_type<coordinate_t>::column_names[3]={"time","ra","dec"};
 
-coordinate_t::coordinate_t() :
-    db_type<coordinate_t>(*this),
-    time(0),
-    ra(0),
-    dec(0) {
-    db_open();
+coordinate_t::coordinate_t() : 
+	db_type<coordinate_t>(*this),
+	time(0),
+	ra(0),
+	dec(0)
+{
+	db_open();
 }
 
 
-coordinate_t::coordinate_t(const coordinate_t &a) :
-    db_type<coordinate_t>(*this),
-    time(a.time),
-    ra(a.ra),
-    dec(a.dec) {
-    db_open();
+coordinate_t::coordinate_t(const coordinate_t &a) : 
+	db_type<coordinate_t>(*this),
+	time(a.time),
+	ra(a.ra),
+	dec(a.dec)
+{
+	db_open();
 }
 
 
-coordinate_t::coordinate_t(const SQL_ROW &a) :
-    db_type<coordinate_t>(*this) {
-    db_open();
-    parse(a);
+coordinate_t::coordinate_t(const SQL_ROW &a) : 
+	db_type<coordinate_t>(*this)
+{
+	db_open();
+	parse(a);
 }
 
 
-coordinate_t::coordinate_t(const std::string &s,const char *tag) :
-    db_type<coordinate_t>(*this) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+coordinate_t::coordinate_t(const std::string &s,const char *tag) : 
+	db_type<coordinate_t>(*this)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
 coordinate_t &coordinate_t::operator =(const coordinate_t &a) {
-    if (&a != this) {
-        time=a.time;
-        ra=a.ra;
-        dec=a.dec;
-    }
-    return (*this);
-}
-
-
-std::string coordinate_t::update_format() const {
-    std::ostringstream rv("");
-
-    rv << "ROW(";
-    for (int i=1; i<3; i++) rv << "?,";
-    rv << "?";
-    rv << ")";
-
-    return rv.str();
-}
-
-
-std::string coordinate_t::insert_format() const {
-    return update_format();
-}
-
-std::string coordinate_t::select_format() const {
-    std::string rv("");
-    for (int i=0; i<2; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string coordinate_t::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << "ROW(";
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << dec;
-    rv << ")";
-    return rv.str();
-}
-
-
-std::string coordinate_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<dec>" << dec << "</dec>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void coordinate_t::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"dec",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> dec;
-        }
-    }
-}
-
-void coordinate_t::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> dec;
-    }
+	if (&a != this) {
+		time=a.time;
+		ra=a.ra;
+		dec=a.dec;
+	}
+	return (*this);
+}
+
+
+std::string coordinate_t::update_format() const
+{	std::ostringstream rv("");
+
+	rv << "ROW(";
+	for (int i=1;i<3;i++) rv << "?,";
+	rv << "?";
+rv << ")";
+
+	return rv.str();
+}
+
+
+std::string coordinate_t::insert_format() const
+{	return update_format();
 }
-
-void coordinate_t::parse(const std::string &s) {
-    SQL_ROW row(&s,3);
-    parse(row);
+
+std::string coordinate_t::select_format() const
+{
+std::string rv("");
+for (int i=0; i<2;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string coordinate_t::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << "ROW(";
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << dec;
+	rv << ")";
+	return rv.str();
 }
 
+
+std::string coordinate_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<dec>" << dec << "</dec>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void coordinate_t::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"dec",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> dec;
+	      }
+	      }
+	      }
+
+	void coordinate_t::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> dec;
+	    }
+	      }
+
+	void coordinate_t::parse(const std::string &s) {
+	      SQL_ROW row(&s,3);
+	      parse(row);
+	      }
+
 template <> const char * const db_type<chirp_parameter_t>::type_name="chirp_parameter_t";
 template <> const char * db_type<chirp_parameter_t>::_search_tag=type_name;
 template <> const int db_type<chirp_parameter_t>::_nfields=2;
-template <> const char * const db_type<chirp_parameter_t>::column_names[2]= {"chirp_limit","fft_len_flags"};
+template <> const char * const db_type<chirp_parameter_t>::column_names[2]={"chirp_limit","fft_len_flags"};
 
-chirp_parameter_t::chirp_parameter_t() :
-    db_type<chirp_parameter_t>(*this),
-    chirp_limit(0),
-    fft_len_flags(0) {
-    db_open();
+chirp_parameter_t::chirp_parameter_t() : 
+	db_type<chirp_parameter_t>(*this),
+	chirp_limit(0),
+	fft_len_flags(0)
+{
+	db_open();
 }
 
 
-chirp_parameter_t::chirp_parameter_t(const chirp_parameter_t &a) :
-    db_type<chirp_parameter_t>(*this),
-    chirp_limit(a.chirp_limit),
-    fft_len_flags(a.fft_len_flags) {
-    db_open();
+chirp_parameter_t::chirp_parameter_t(const chirp_parameter_t &a) : 
+	db_type<chirp_parameter_t>(*this),
+	chirp_limit(a.chirp_limit),
+	fft_len_flags(a.fft_len_flags)
+{
+	db_open();
 }
 
 
-chirp_parameter_t::chirp_parameter_t(const SQL_ROW &a) :
-    db_type<chirp_parameter_t>(*this) {
-    db_open();
-    parse(a);
+chirp_parameter_t::chirp_parameter_t(const SQL_ROW &a) : 
+	db_type<chirp_parameter_t>(*this)
+{
+	db_open();
+	parse(a);
 }
 
 
-chirp_parameter_t::chirp_parameter_t(const std::string &s,const char *tag) :
-    db_type<chirp_parameter_t>(*this) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+chirp_parameter_t::chirp_parameter_t(const std::string &s,const char *tag) : 
+	db_type<chirp_parameter_t>(*this)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
 chirp_parameter_t &chirp_parameter_t::operator =(const chirp_parameter_t &a) {
-    if (&a != this) {
-        chirp_limit=a.chirp_limit;
-        fft_len_flags=a.fft_len_flags;
-    }
-    return (*this);
+	if (&a != this) {
+		chirp_limit=a.chirp_limit;
+		fft_len_flags=a.fft_len_flags;
+	}
+	return (*this);
 }
 
 
-std::string chirp_parameter_t::update_format() const {
-    std::ostringstream rv("");
+std::string chirp_parameter_t::update_format() const
+{	std::ostringstream rv("");
 
-    rv << "ROW(";
-    for (int i=1; i<2; i++) rv << "?,";
-    rv << "?";
-    rv << ")";
+	rv << "ROW(";
+	for (int i=1;i<2;i++) rv << "?,";
+	rv << "?";
+rv << ")";
 
-    return rv.str();
+	return rv.str();
 }
 
 
-std::string chirp_parameter_t::insert_format() const {
-    return update_format();
+std::string chirp_parameter_t::insert_format() const
+{	return update_format();
 }
 
-std::string chirp_parameter_t::select_format() const {
-    std::string rv("");
-    for (int i=0; i<1; i++) rv+="?,";
-    rv+="?";
-    return rv;
+std::string chirp_parameter_t::select_format() const
+{
+std::string rv("");
+for (int i=0; i<1;i++) rv+="?,";
+rv+="?";
+return rv;
 }
 
-std::string chirp_parameter_t::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
+std::string chirp_parameter_t::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
 
-    rv.precision(14);
-    rv << "ROW(";
-    rv << chirp_limit;
-    rv << ',';
-    rv << fft_len_flags;
-    rv << ")";
-    return rv.str();
+	rv.precision(14);
+	rv << "ROW(";
+	rv << chirp_limit;
+	rv << ',';
+	rv << fft_len_flags;
+	rv << ")";
+	return rv.str();
 }
 
 
-std::string chirp_parameter_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
+std::string chirp_parameter_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	rv << xml_indent() << "<chirp_limit>" << chirp_limit << "</chirp_limit>\n";
+	rv << xml_indent() << "<fft_len_flags>" << fft_len_flags << "</fft_len_flags>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void chirp_parameter_t::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"chirp_limit",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_limit;
+	      }
+	    if (extract_xml_record(field,"fft_len_flags",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len_flags;
+	      }
+	      }
+	      }
+
+	void chirp_parameter_t::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> chirp_limit;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> fft_len_flags;
+	    }
+	      }
+
+	void chirp_parameter_t::parse(const std::string &s) {
+	      SQL_ROW row(&s,2);
+	      parse(row);
+	      }
 
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    rv << xml_indent() << "<chirp_limit>" << chirp_limit << "</chirp_limit>\n";
-    rv << xml_indent() << "<fft_len_flags>" << fft_len_flags << "</fft_len_flags>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
+template <> const char * const db_type<subband_description_t>::type_name="subband_description_t";
+template <> const char * db_type<subband_description_t>::_search_tag=type_name;
+template <> const int db_type<subband_description_t>::_nfields=4;
+template <> const char * const db_type<subband_description_t>::column_names[4]={"number","center","base","sample_rate"};
+
+subband_description_t::subband_description_t() : 
+	db_type<subband_description_t>(*this),
+	number(0),
+	center(0),
+	base(0),
+	sample_rate(0)
+{
+	db_open();
 }
 
 
-void chirp_parameter_t::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"chirp_limit",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_limit;
-        }
-        if (extract_xml_record(field,"fft_len_flags",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len_flags;
-        }
-    }
+subband_description_t::subband_description_t(const subband_description_t &a) : 
+	db_type<subband_description_t>(*this),
+	number(a.number),
+	center(a.center),
+	base(a.base),
+	sample_rate(a.sample_rate)
+{
+	db_open();
 }
 
-void chirp_parameter_t::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> chirp_limit;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> fft_len_flags;
-    }
-}
 
-void chirp_parameter_t::parse(const std::string &s) {
-    SQL_ROW row(&s,2);
-    parse(row);
+subband_description_t::subband_description_t(const SQL_ROW &a) : 
+	db_type<subband_description_t>(*this)
+{
+	db_open();
+	parse(a);
 }
 
-template <> const char * const db_type<subband_description_t>::type_name="subband_description_t";
-template <> const char * db_type<subband_description_t>::_search_tag=type_name;
-template <> const int db_type<subband_description_t>::_nfields=4;
-template <> const char * const db_type<subband_description_t>::column_names[4]= {"number","center","base","sample_rate"};
 
-subband_description_t::subband_description_t() :
-    db_type<subband_description_t>(*this),
-    number(0),
-    center(0),
-    base(0),
-    sample_rate(0) {
-    db_open();
+subband_description_t::subband_description_t(const std::string &s,const char *tag) : 
+	db_type<subband_description_t>(*this)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-subband_description_t::subband_description_t(const subband_description_t &a) :
-    db_type<subband_description_t>(*this),
-    number(a.number),
-    center(a.center),
-    base(a.base),
-    sample_rate(a.sample_rate) {
-    db_open();
+subband_description_t &subband_description_t::operator =(const subband_description_t &a) {
+	if (&a != this) {
+		number=a.number;
+		center=a.center;
+		base=a.base;
+		sample_rate=a.sample_rate;
+	}
+	return (*this);
 }
 
 
-subband_description_t::subband_description_t(const SQL_ROW &a) :
-    db_type<subband_description_t>(*this) {
-    db_open();
-    parse(a);
+std::string subband_description_t::update_format() const
+{	std::ostringstream rv("");
+
+	rv << "ROW(";
+	for (int i=1;i<4;i++) rv << "?,";
+	rv << "?";
+rv << ")";
+
+	return rv.str();
 }
 
 
-subband_description_t::subband_description_t(const std::string &s,const char *tag) :
-    db_type<subband_description_t>(*this) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+std::string subband_description_t::insert_format() const
+{	return update_format();
 }
 
+std::string subband_description_t::select_format() const
+{
+std::string rv("");
+for (int i=0; i<3;i++) rv+="?,";
+rv+="?";
+return rv;
+}
 
-subband_description_t &subband_description_t::operator =(const subband_description_t &a) {
-    if (&a != this) {
-        number=a.number;
-        center=a.center;
-        base=a.base;
-        sample_rate=a.sample_rate;
-    }
-    return (*this);
-}
-
-
-std::string subband_description_t::update_format() const {
-    std::ostringstream rv("");
-
-    rv << "ROW(";
-    for (int i=1; i<4; i++) rv << "?,";
-    rv << "?";
-    rv << ")";
-
-    return rv.str();
-}
-
-
-std::string subband_description_t::insert_format() const {
-    return update_format();
-}
-
-std::string subband_description_t::select_format() const {
-    std::string rv("");
-    for (int i=0; i<3; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string subband_description_t::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << "ROW(";
-    rv << number;
-    rv << ',';
-    rv << center;
-    rv << ',';
-    rv << base;
-    rv << ',';
-    rv << sample_rate;
-    rv << ")";
-    return rv.str();
-}
-
-
-std::string subband_description_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    rv << xml_indent() << "<number>" << number << "</number>\n";
-    rv << xml_indent() << "<center>" << center << "</center>\n";
-    rv << xml_indent() << "<base>" << base << "</base>\n";
-    rv << xml_indent() << "<sample_rate>" << sample_rate << "</sample_rate>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void subband_description_t::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"number",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> number;
-        }
-        if (extract_xml_record(field,"center",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> center;
-        }
-        if (extract_xml_record(field,"base",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> base;
-        }
-        if (extract_xml_record(field,"sample_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> sample_rate;
-        }
-    }
-}
-
-void subband_description_t::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> number;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> center;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> base;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> sample_rate;
-    }
-}
-
-void subband_description_t::parse(const std::string &s) {
-    SQL_ROW row(&s,4);
-    parse(row);
+std::string subband_description_t::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << "ROW(";
+	rv << number;
+	rv << ',';
+	rv << center;
+	rv << ',';
+	rv << base;
+	rv << ',';
+	rv << sample_rate;
+	rv << ")";
+	return rv.str();
 }
 
+
+std::string subband_description_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	rv << xml_indent() << "<number>" << number << "</number>\n";
+	rv << xml_indent() << "<center>" << center << "</center>\n";
+	rv << xml_indent() << "<base>" << base << "</base>\n";
+	rv << xml_indent() << "<sample_rate>" << sample_rate << "</sample_rate>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void subband_description_t::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"number",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> number;
+	      }
+	    if (extract_xml_record(field,"center",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> center;
+	      }
+	    if (extract_xml_record(field,"base",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> base;
+	      }
+	    if (extract_xml_record(field,"sample_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> sample_rate;
+	      }
+	      }
+	      }
+
+	void subband_description_t::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> number;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> center;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> base;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> sample_rate;
+	    }
+	      }
+
+	void subband_description_t::parse(const std::string &s) {
+	      SQL_ROW row(&s,4);
+	      parse(row);
+	      }
+
 template <> const char * const db_type<data_description_t>::type_name="data_description_t";
 template <> const char * db_type<data_description_t>::_search_tag=type_name;
 template <> const int db_type<data_description_t>::_nfields=9;
-template <> const char * const db_type<data_description_t>::column_names[9]= {"start_ra","start_dec","end_ra","end_dec","true_angle_range","time_recorded","time_recorded_jd","nsamples","coords"};
-
-data_description_t::data_description_t() :
-    db_type<data_description_t>(*this),
-    start_ra(0),
-    start_dec(0),
-    end_ra(0),
-    end_dec(0),
-    true_angle_range(0),
-    time_recorded_jd(0),
-    nsamples(0),
-    coords((coordinate_t *)0,0,_x_xml_values) {
-    db_open();
-    time_recorded[0]=0;
+template <> const char * const db_type<data_description_t>::column_names[9]={"start_ra","start_dec","end_ra","end_dec","true_angle_range","time_recorded","time_recorded_jd","nsamples","coords"};
+
+data_description_t::data_description_t() : 
+	db_type<data_description_t>(*this),
+	start_ra(0),
+	start_dec(0),
+	end_ra(0),
+	end_dec(0),
+	true_angle_range(0),
+	time_recorded_jd(0),
+	nsamples(0),
+	coords((coordinate_t *)0,0,_x_xml_values)
+{
+	db_open();
+	time_recorded[0]=0;
 }
 
 
-data_description_t::data_description_t(const data_description_t &a) :
-    db_type<data_description_t>(*this),
-    start_ra(a.start_ra),
-    start_dec(a.start_dec),
-    end_ra(a.end_ra),
-    end_dec(a.end_dec),
-    true_angle_range(a.true_angle_range),
-    time_recorded_jd(a.time_recorded_jd),
-    nsamples(a.nsamples),
-    coords(a.coords) {
-    db_open();
-    strcpy(time_recorded,a.time_recorded);
+data_description_t::data_description_t(const data_description_t &a) : 
+	db_type<data_description_t>(*this),
+	start_ra(a.start_ra),
+	start_dec(a.start_dec),
+	end_ra(a.end_ra),
+	end_dec(a.end_dec),
+	true_angle_range(a.true_angle_range),
+	time_recorded_jd(a.time_recorded_jd),
+	nsamples(a.nsamples),
+	coords(a.coords)
+{
+	db_open();
+	strcpy(time_recorded,a.time_recorded);
 }
 
 
-data_description_t::data_description_t(const SQL_ROW &a) :
-    db_type<data_description_t>(*this) {
-    db_open();
-    parse(a);
+data_description_t::data_description_t(const SQL_ROW &a) : 
+	db_type<data_description_t>(*this)
+{
+	db_open();
+	parse(a);
 }
 
 
-data_description_t::data_description_t(const std::string &s,const char *tag) :
-    db_type<data_description_t>(*this) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+data_description_t::data_description_t(const std::string &s,const char *tag) : 
+	db_type<data_description_t>(*this)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
 data_description_t &data_description_t::operator =(const data_description_t &a) {
-    if (&a != this) {
-        start_ra=a.start_ra;
-        start_dec=a.start_dec;
-        end_ra=a.end_ra;
-        end_dec=a.end_dec;
-        true_angle_range=a.true_angle_range;
-        time_recorded_jd=a.time_recorded_jd;
-        nsamples=a.nsamples;
-        {
-            coords.clear();
-            std::vector<coordinate_t>::const_iterator i(a.coords.begin());
-            for (; i!=a.coords.end(); i++) {
-                coords.push_back(*i);
-            }
-        }
-        strcpy(time_recorded,a.time_recorded);
-    }
-    return (*this);
-}
-
-
-std::string data_description_t::update_format() const {
-    std::ostringstream rv("");
-
-    rv << "ROW(";
-    for (int i=1; i<9; i++) rv << "?,";
-    rv << "?";
-    rv << ")";
-
-    return rv.str();
-}
-
-
-std::string data_description_t::insert_format() const {
-    return update_format();
-}
-
-std::string data_description_t::select_format() const {
-    std::string rv("");
-    for (int i=0; i<8; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string data_description_t::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << "ROW(";
-    rv << start_ra;
-    rv << ',';
-    rv << start_dec;
-    rv << ',';
-    rv << end_ra;
-    rv << ',';
-    rv << end_dec;
-    rv << ',';
-    rv << true_angle_range;
-    rv << ',';
-    rv << "'" << time_recorded << "'";
-    rv << ',';
-    rv << time_recorded_jd;
-    rv << ',';
-    rv << nsamples;
-    rv << ',';
-    rv << "LIST {";
-    {
-        std::vector<coordinate_t>::const_iterator p=coords.begin();
-        for (; p<coords.end(); p++) {
-            rv << p->print();
-            if (p != coords.end()-1) {
-                rv << ',';
-            } else {
-                rv << "}";
-            }
-        }
-    }
-    rv << ")";
-    return rv.str();
-}
-
-
-std::string data_description_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    rv << xml_indent() << "<start_ra>" << start_ra << "</start_ra>\n";
-    rv << xml_indent() << "<start_dec>" << start_dec << "</start_dec>\n";
-    rv << xml_indent() << "<end_ra>" << end_ra << "</end_ra>\n";
-    rv << xml_indent() << "<end_dec>" << end_dec << "</end_dec>\n";
-    rv << xml_indent() << "<true_angle_range>" << true_angle_range << "</true_angle_range>\n";
-    {
-        std::string enc_field=xml_encode_string(time_recorded,std::min(strlen(time_recorded),sizeof(time_recorded)));
-        rv << xml_indent() << "<time_recorded>";
-        rv << enc_field << "</time_recorded>\n";
-    }
-    rv << xml_indent() << "<time_recorded_jd>" << time_recorded_jd << "</time_recorded_jd>\n";
-    rv << xml_indent() << "<nsamples>" << nsamples << "</nsamples>\n";
-    if (coords.size()) {
-        rv << xml_indent() << "<coords";
-        {
-            std::string enc_string=coords.print_xml();
-            rv << ">\n" ;
-            rv << enc_string;
-        }
-    }
-    rv << xml_indent(-2);
-    rv << "</coords>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void data_description_t::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"start_ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> start_ra;
-        }
-        if (extract_xml_record(field,"start_dec",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> start_dec;
-        }
-        if (extract_xml_record(field,"end_ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> end_ra;
-        }
-        if (extract_xml_record(field,"end_dec",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> end_dec;
-        }
-        if (extract_xml_record(field,"true_angle_range",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> true_angle_range;
-        }
-        if (extract_xml_record(field,"time_recorded",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(time_recorded,(const char *)&(in.front()),std::min(in.size(),(size_t)255));
-            time_recorded[std::min(in.size(),(size_t)254)]=0;
-        }
-        if (extract_xml_record(field,"time_recorded_jd",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time_recorded_jd;
-        }
-        if (extract_xml_record(field,"nsamples",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> nsamples;
-        }
-        coords.clear();
-        if (extract_xml_record(field,"coords",sub)) {
-            pos=0;
-            while ((pos=sub.find("<coordinate_t",pos)) != std::string::npos) {
-                coords.push_back(coordinate_t(std::string(sub.c_str()+pos)));
-                pos=sub.find("</coordinate_t",pos);
-                pos=sub.find(">",pos);
-            }
-        }
-    }
-}
-
-void data_description_t::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> start_ra;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> start_dec;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> end_ra;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> end_dec;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> true_angle_range;
-    }
-    {
-        strncpy(time_recorded,s[5]->c_str(),255);
-        time_recorded[254]=0;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> time_recorded_jd;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> nsamples;
-    }
-    {
-        std::string::size_type p,q;
-        int i;
-        coords.clear();
-        SQL_ROW tmp(s[8]);
-        for (i=0; i<tmp.argc(); i++) {
-            coords.push_back(coordinate_t(SQL_ROW(tmp[i])));
-        }
-    }
-}
-
-void data_description_t::parse(const std::string &s) {
-    SQL_ROW row(&s,9);
-    parse(row);
+	if (&a != this) {
+		start_ra=a.start_ra;
+		start_dec=a.start_dec;
+		end_ra=a.end_ra;
+		end_dec=a.end_dec;
+		true_angle_range=a.true_angle_range;
+		time_recorded_jd=a.time_recorded_jd;
+		nsamples=a.nsamples;
+		{
+		  coords.clear();
+		  std::vector<coordinate_t>::const_iterator i(a.coords.begin());
+		  for (;i!=a.coords.end();i++) {
+		    coords.push_back(*i); 
+		  }
+		}
+	strcpy(time_recorded,a.time_recorded);
+	}
+	return (*this);
+}
+
+
+std::string data_description_t::update_format() const
+{	std::ostringstream rv("");
+
+	rv << "ROW(";
+	for (int i=1;i<9;i++) rv << "?,";
+	rv << "?";
+rv << ")";
+
+	return rv.str();
+}
+
+
+std::string data_description_t::insert_format() const
+{	return update_format();
 }
 
+std::string data_description_t::select_format() const
+{
+std::string rv("");
+for (int i=0; i<8;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string data_description_t::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << "ROW(";
+	rv << start_ra;
+	rv << ',';
+	rv << start_dec;
+	rv << ',';
+	rv << end_ra;
+	rv << ',';
+	rv << end_dec;
+	rv << ',';
+	rv << true_angle_range;
+	rv << ',';
+	rv << "'" << time_recorded << "'";
+	rv << ',';
+	rv << time_recorded_jd;
+	rv << ',';
+	rv << nsamples;
+	rv << ',';
+	rv << "LIST {";
+	{
+	std::vector<coordinate_t>::const_iterator p=coords.begin();
+	for (;p<coords.end();p++) {
+	  rv << p->print();
+	  if (p != coords.end()-1) {
+	    rv << ',';
+	  } else {
+	    rv << "}";
+	  }
+	}
+	}
+	rv << ")";
+	return rv.str();
+}
+
+
+std::string data_description_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	rv << xml_indent() << "<start_ra>" << start_ra << "</start_ra>\n";
+	rv << xml_indent() << "<start_dec>" << start_dec << "</start_dec>\n";
+	rv << xml_indent() << "<end_ra>" << end_ra << "</end_ra>\n";
+	rv << xml_indent() << "<end_dec>" << end_dec << "</end_dec>\n";
+	rv << xml_indent() << "<true_angle_range>" << true_angle_range << "</true_angle_range>\n";
+	{
+	  std::string enc_field=xml_encode_string(time_recorded,std::min(strlen(time_recorded),sizeof(time_recorded)));
+	  rv << xml_indent() << "<time_recorded>";
+	  rv << enc_field << "</time_recorded>\n";
+	}
+	rv << xml_indent() << "<time_recorded_jd>" << time_recorded_jd << "</time_recorded_jd>\n";
+	rv << xml_indent() << "<nsamples>" << nsamples << "</nsamples>\n";
+	if (coords.size()) {
+	  rv << xml_indent() << "<coords";
+	  {
+	    std::string enc_string=coords.print_xml();
+	    rv << ">\n" ;
+	    rv << enc_string;
+	  }
+}
+	rv << xml_indent(-2);
+	rv << "</coords>\n"; 
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void data_description_t::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"start_ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> start_ra;
+	      }
+	    if (extract_xml_record(field,"start_dec",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> start_dec;
+	      }
+	    if (extract_xml_record(field,"end_ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> end_ra;
+	      }
+	    if (extract_xml_record(field,"end_dec",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> end_dec;
+	      }
+	    if (extract_xml_record(field,"true_angle_range",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> true_angle_range;
+	      }
+	    if (extract_xml_record(field,"time_recorded",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(time_recorded,(const char *)&(in.front()),std::min(in.size(),(size_t)255));
+	        time_recorded[std::min(in.size(),(size_t)254)]=0;
+	      }
+	    if (extract_xml_record(field,"time_recorded_jd",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time_recorded_jd;
+	      }
+	    if (extract_xml_record(field,"nsamples",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> nsamples;
+	      }
+	    coords.clear();
+	    if (extract_xml_record(field,"coords",sub)) {
+	      pos=0;
+	      while ((pos=sub.find("<coordinate_t",pos)) != std::string::npos) { 
+	        coords.push_back(coordinate_t(std::string(sub.c_str()+pos))); 
+	         pos=sub.find("</coordinate_t",pos);
+	      pos=sub.find(">",pos);
+	      }
+	    }
+	      }
+	      }
+
+	void data_description_t::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> start_ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> start_dec;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> end_ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> end_dec;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> true_angle_range;
+	    }
+	  {  
+	        strncpy(time_recorded,s[5]->c_str(),255);
+	        time_recorded[254]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> time_recorded_jd;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> nsamples;
+	    }
+	  {  
+	  std::string::size_type p,q;
+	  int i;
+	    coords.clear();
+	      SQL_ROW tmp(s[8]); 
+	      for (i=0;i<tmp.argc();i++) {
+	 coords.push_back(coordinate_t(SQL_ROW(tmp[i])));
+	      }
+	    }
+	      }
+
+	void data_description_t::parse(const std::string &s) {
+	      SQL_ROW row(&s,9);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<receiver_config>::table_name="receiver_config";
 template <> const char * db_table<receiver_config>::_search_tag=table_name;
 template <> const int db_table<receiver_config>::_nfields=16;
-template <> const char * const db_table<receiver_config>::column_names[16]= {"id","s4_id","name","beam_width","center_freq","latitude","longitude","elevation","diameter","az_orientation","az_corr_coeff","zen_corr_coeff","array_az_ellipse","array_za_ellipse","array_angle","min_vgc"};
-
-receiver_config::receiver_config() :
-    db_table<receiver_config>(*this,-1),
-    id(0),
-    s4_id(0),
-    beam_width(0),
-    center_freq(0),
-    latitude(0),
-    longitude(0),
-    elevation(0),
-    diameter(0),
-    az_orientation(0),
-    az_corr_coeff((float *)0,0,_x_csv),
-    zen_corr_coeff((float *)0,0,_x_csv),
-    array_az_ellipse(0),
-    array_za_ellipse(0),
-    array_angle(0),
-    min_vgc(0) {
-    db_open();
-    name[0]=0;
-}
-
-
-receiver_config::receiver_config(const receiver_config &a) :
-    db_table<receiver_config>(*this,-1),
-    id(a.id),
-    s4_id(a.s4_id),
-    beam_width(a.beam_width),
-    center_freq(a.center_freq),
-    latitude(a.latitude),
-    longitude(a.longitude),
-    elevation(a.elevation),
-    diameter(a.diameter),
-    az_orientation(a.az_orientation),
-    az_corr_coeff(a.az_corr_coeff),
-    zen_corr_coeff(a.zen_corr_coeff),
-    array_az_ellipse(a.array_az_ellipse),
-    array_za_ellipse(a.array_za_ellipse),
-    array_angle(a.array_angle),
-    min_vgc(a.min_vgc) {
-    db_open();
-    strcpy(name,a.name);
-}
-
-
-receiver_config::receiver_config(const SQL_ROW &a) :
-    db_table<receiver_config>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-receiver_config::receiver_config(const std::string &s,const char *tag) :
-    db_table<receiver_config>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+template <> const char * const db_table<receiver_config>::column_names[16]={"id","s4_id","name","beam_width","center_freq","latitude","longitude","elevation","diameter","az_orientation","az_corr_coeff","zen_corr_coeff","array_az_ellipse","array_za_ellipse","array_angle","min_vgc"};
+
+receiver_config::receiver_config() : 
+	db_table<receiver_config>(*this,-1),
+	id(0),
+	s4_id(0),
+	beam_width(0),
+	center_freq(0),
+	latitude(0),
+	longitude(0),
+	elevation(0),
+	diameter(0),
+	az_orientation(0),
+	az_corr_coeff((float *)0,0,_x_csv),
+	zen_corr_coeff((float *)0,0,_x_csv),
+	array_az_ellipse(0),
+	array_za_ellipse(0),
+	array_angle(0),
+	min_vgc(0)
+{
+	db_open();
+	name[0]=0;
+}
+
+
+receiver_config::receiver_config(const receiver_config &a) : 
+	db_table<receiver_config>(*this,-1),
+	id(a.id),
+	s4_id(a.s4_id),
+	beam_width(a.beam_width),
+	center_freq(a.center_freq),
+	latitude(a.latitude),
+	longitude(a.longitude),
+	elevation(a.elevation),
+	diameter(a.diameter),
+	az_orientation(a.az_orientation),
+	az_corr_coeff(a.az_corr_coeff),
+	zen_corr_coeff(a.zen_corr_coeff),
+	array_az_ellipse(a.array_az_ellipse),
+	array_za_ellipse(a.array_za_ellipse),
+	array_angle(a.array_angle),
+	min_vgc(a.min_vgc)
+{
+	db_open();
+	strcpy(name,a.name);
 }
 
 
-receiver_config &receiver_config::operator =(const receiver_config &a) {
-    if (&a != this) {
-        id=a.id;
-        s4_id=a.s4_id;
-        beam_width=a.beam_width;
-        center_freq=a.center_freq;
-        latitude=a.latitude;
-        longitude=a.longitude;
-        elevation=a.elevation;
-        diameter=a.diameter;
-        az_orientation=a.az_orientation;
-        {
-            az_corr_coeff.clear();
-            std::vector<float>::const_iterator i(a.az_corr_coeff.begin());
-            for (; i!=a.az_corr_coeff.end(); i++) {
-                az_corr_coeff.push_back(*i);
-            }
-        }
-        {
-            zen_corr_coeff.clear();
-            std::vector<float>::const_iterator i(a.zen_corr_coeff.begin());
-            for (; i!=a.zen_corr_coeff.end(); i++) {
-                zen_corr_coeff.push_back(*i);
-            }
-        }
-        array_az_ellipse=a.array_az_ellipse;
-        array_za_ellipse=a.array_za_ellipse;
-        array_angle=a.array_angle;
-        min_vgc=a.min_vgc;
-        strcpy(name,a.name);
-    }
-    return (*this);
-}
-
-
-std::string receiver_config::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<16; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string receiver_config::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string receiver_config::select_format() const {
-    std::string rv("");
-    for (int i=0; i<15; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string receiver_config::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << s4_id;
-    rv << ',';
-    rv << "'" << name << "'";
-    rv << ',';
-    rv << beam_width;
-    rv << ',';
-    rv << center_freq;
-    rv << ',';
-    rv << latitude;
-    rv << ',';
-    rv << longitude;
-    rv << ',';
-    rv << elevation;
-    rv << ',';
-    rv << diameter;
-    rv << ',';
-    rv << az_orientation;
-    rv << ',';
-    rv << "LIST {";
-    {
-        std::vector<float>::const_iterator p=az_corr_coeff.begin();
-        for (; p<az_corr_coeff.end(); p++) {
-            rv << *p;
-            if (p != az_corr_coeff.end()-1) {
-                rv << ',';
-            } else {
-                rv << "}";
-            }
-        }
-    }
-    rv << ',';
-    rv << "LIST {";
-    {
-        std::vector<float>::const_iterator p=zen_corr_coeff.begin();
-        for (; p<zen_corr_coeff.end(); p++) {
-            rv << *p;
-            if (p != zen_corr_coeff.end()-1) {
-                rv << ',';
-            } else {
-                rv << "}";
-            }
-        }
-    }
-    rv << ',';
-    rv << array_az_ellipse;
-    rv << ',';
-    rv << array_za_ellipse;
-    rv << ',';
-    rv << array_angle;
-    rv << ',';
-    rv << min_vgc;
-    return rv.str();
-}
-
-
-std::string receiver_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<s4_id>" << s4_id << "</s4_id>\n";
-    {
-        std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
-        rv << xml_indent() << "<name>";
-        rv << enc_field << "</name>\n";
-    }
-    rv << xml_indent() << "<beam_width>" << beam_width << "</beam_width>\n";
-    rv << xml_indent() << "<center_freq>" << center_freq << "</center_freq>\n";
-    rv << xml_indent() << "<latitude>" << latitude << "</latitude>\n";
-    rv << xml_indent() << "<longitude>" << longitude << "</longitude>\n";
-    rv << xml_indent() << "<elevation>" << elevation << "</elevation>\n";
-    rv << xml_indent() << "<diameter>" << diameter << "</diameter>\n";
-    rv << xml_indent() << "<az_orientation>" << az_orientation << "</az_orientation>\n";
-    if (az_corr_coeff.size()) {
-        rv << xml_indent() << "<az_corr_coeff";
-        {
-            std::string enc_string=az_corr_coeff.print_xml();
-            rv << " length=" << enc_string.size() << " encoding=\"" << xml_encoding_names[az_corr_coeff.encoding] << "\">" ;
-            rv << enc_string;
-        }
-    }
-    rv << "</az_corr_coeff>\n";
-    if (zen_corr_coeff.size()) {
-        rv << xml_indent() << "<zen_corr_coeff";
-        {
-            std::string enc_string=zen_corr_coeff.print_xml();
-            rv << " length=" << enc_string.size() << " encoding=\"" << xml_encoding_names[zen_corr_coeff.encoding] << "\">" ;
-            rv << enc_string;
-        }
-    }
-    rv << "</zen_corr_coeff>\n";
-    rv << xml_indent() << "<array_az_ellipse>" << array_az_ellipse << "</array_az_ellipse>\n";
-    rv << xml_indent() << "<array_za_ellipse>" << array_za_ellipse << "</array_za_ellipse>\n";
-    rv << xml_indent() << "<array_angle>" << array_angle << "</array_angle>\n";
-    rv << xml_indent() << "<min_vgc>" << min_vgc << "</min_vgc>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void receiver_config::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"s4_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> s4_id;
-        }
-        if (extract_xml_record(field,"name",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)255));
-            name[std::min(in.size(),(size_t)254)]=0;
-        }
-        if (extract_xml_record(field,"beam_width",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> beam_width;
-        }
-        if (extract_xml_record(field,"center_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> center_freq;
-        }
-        if (extract_xml_record(field,"latitude",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> latitude;
-        }
-        if (extract_xml_record(field,"longitude",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> longitude;
-        }
-        if (extract_xml_record(field,"elevation",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> elevation;
-        }
-        if (extract_xml_record(field,"diameter",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> diameter;
-        }
-        if (extract_xml_record(field,"az_orientation",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> az_orientation;
-        }
-        az_corr_coeff.clear();
-        if (extract_xml_record(field,"az_corr_coeff",sub)) {
-            pos=sub.find(">");
-            do {
-                if (pos!=std::string::npos) {
-                    do {
-                        pos++;
-                    } while ((sub[pos]=='\n') || (sub[pos]==','));
-                    std::istringstream in(std::string(sub.c_str()+pos));
-                    float tmp;
-                    in >> tmp;
-                    az_corr_coeff.push_back(tmp);
-                }
-            } while ((pos=sub.find(",",pos)) != std::string::npos);
-        }
-        zen_corr_coeff.clear();
-        if (extract_xml_record(field,"zen_corr_coeff",sub)) {
-            pos=sub.find(">");
-            do {
-                if (pos!=std::string::npos) {
-                    do {
-                        pos++;
-                    } while ((sub[pos]=='\n') || (sub[pos]==','));
-                    std::istringstream in(std::string(sub.c_str()+pos));
-                    float tmp;
-                    in >> tmp;
-                    zen_corr_coeff.push_back(tmp);
-                }
-            } while ((pos=sub.find(",",pos)) != std::string::npos);
-        }
-        if (extract_xml_record(field,"array_az_ellipse",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> array_az_ellipse;
-        }
-        if (extract_xml_record(field,"array_za_ellipse",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> array_za_ellipse;
-        }
-        if (extract_xml_record(field,"array_angle",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> array_angle;
-        }
-        if (extract_xml_record(field,"min_vgc",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_vgc;
-        }
-    }
-}
-
-void receiver_config::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> s4_id;
-    }
-    {
-        strncpy(name,s[2]->c_str(),255);
-        name[254]=0;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> beam_width;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> center_freq;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> latitude;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> longitude;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> elevation;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> diameter;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> az_orientation;
-    }
-    {
-        std::string::size_type p,q;
-        int i;
-        az_corr_coeff.clear();
-        SQL_ROW tmp(s[10]);
-        for (i=0; i<tmp.argc(); i++) {
-            std::istringstream in(*(tmp[i]));
-            float tmp0;
-            in >> tmp0;
-            az_corr_coeff.push_back(tmp0);
-        }
-    }
-    {
-        std::string::size_type p,q;
-        int i;
-        zen_corr_coeff.clear();
-        SQL_ROW tmp(s[11]);
-        for (i=0; i<tmp.argc(); i++) {
-            std::istringstream in(*(tmp[i]));
-            float tmp0;
-            in >> tmp0;
-            zen_corr_coeff.push_back(tmp0);
-        }
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> array_az_ellipse;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> array_za_ellipse;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> array_angle;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> min_vgc;
-    }
-}
-
-void receiver_config::parse(const std::string &s) {
-    SQL_ROW row(&s,16);
-    parse(row);
+receiver_config::receiver_config(const SQL_ROW &a) : 
+	db_table<receiver_config>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+receiver_config::receiver_config(const std::string &s,const char *tag) : 
+	db_table<receiver_config>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
+
+receiver_config &receiver_config::operator =(const receiver_config &a) {
+	if (&a != this) {
+		id=a.id;
+		s4_id=a.s4_id;
+		beam_width=a.beam_width;
+		center_freq=a.center_freq;
+		latitude=a.latitude;
+		longitude=a.longitude;
+		elevation=a.elevation;
+		diameter=a.diameter;
+		az_orientation=a.az_orientation;
+		{
+		  az_corr_coeff.clear();
+		  std::vector<float>::const_iterator i(a.az_corr_coeff.begin());
+		  for (;i!=a.az_corr_coeff.end();i++) {
+		    az_corr_coeff.push_back(*i); 
+		  }
+		}
+		{
+		  zen_corr_coeff.clear();
+		  std::vector<float>::const_iterator i(a.zen_corr_coeff.begin());
+		  for (;i!=a.zen_corr_coeff.end();i++) {
+		    zen_corr_coeff.push_back(*i); 
+		  }
+		}
+		array_az_ellipse=a.array_az_ellipse;
+		array_za_ellipse=a.array_za_ellipse;
+		array_angle=a.array_angle;
+		min_vgc=a.min_vgc;
+	strcpy(name,a.name);
+	}
+	return (*this);
+}
+
+
+std::string receiver_config::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<16;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string receiver_config::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string receiver_config::select_format() const
+{
+std::string rv("");
+for (int i=0; i<15;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string receiver_config::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << s4_id;
+	rv << ',';
+	rv << "'" << name << "'";
+	rv << ',';
+	rv << beam_width;
+	rv << ',';
+	rv << center_freq;
+	rv << ',';
+	rv << latitude;
+	rv << ',';
+	rv << longitude;
+	rv << ',';
+	rv << elevation;
+	rv << ',';
+	rv << diameter;
+	rv << ',';
+	rv << az_orientation;
+	rv << ',';
+	rv << "LIST {";
+	{
+	std::vector<float>::const_iterator p=az_corr_coeff.begin();
+	for (;p<az_corr_coeff.end();p++) {
+	  rv << *p;
+	  if (p != az_corr_coeff.end()-1) {
+	    rv << ',';
+	  } else {
+	    rv << "}";
+	  }
+	}
+	}
+	rv << ',';
+	rv << "LIST {";
+	{
+	std::vector<float>::const_iterator p=zen_corr_coeff.begin();
+	for (;p<zen_corr_coeff.end();p++) {
+	  rv << *p;
+	  if (p != zen_corr_coeff.end()-1) {
+	    rv << ',';
+	  } else {
+	    rv << "}";
+	  }
+	}
+	}
+	rv << ',';
+	rv << array_az_ellipse;
+	rv << ',';
+	rv << array_za_ellipse;
+	rv << ',';
+	rv << array_angle;
+	rv << ',';
+	rv << min_vgc;
+	return rv.str();
+}
+
+
+std::string receiver_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<s4_id>" << s4_id << "</s4_id>\n";
+	{
+	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
+	  rv << xml_indent() << "<name>";
+	  rv << enc_field << "</name>\n";
+	}
+	rv << xml_indent() << "<beam_width>" << beam_width << "</beam_width>\n";
+	rv << xml_indent() << "<center_freq>" << center_freq << "</center_freq>\n";
+	rv << xml_indent() << "<latitude>" << latitude << "</latitude>\n";
+	rv << xml_indent() << "<longitude>" << longitude << "</longitude>\n";
+	rv << xml_indent() << "<elevation>" << elevation << "</elevation>\n";
+	rv << xml_indent() << "<diameter>" << diameter << "</diameter>\n";
+	rv << xml_indent() << "<az_orientation>" << az_orientation << "</az_orientation>\n";
+	if (az_corr_coeff.size()) {
+	  rv << xml_indent() << "<az_corr_coeff";
+	  {
+	    std::string enc_string=az_corr_coeff.print_xml();
+	    rv << " length=" << enc_string.size() << " encoding=\"" << xml_encoding_names[az_corr_coeff.encoding] << "\">" ;
+	    rv << enc_string;
+	  }
+}
+	rv << "</az_corr_coeff>\n"; 
+	if (zen_corr_coeff.size()) {
+	  rv << xml_indent() << "<zen_corr_coeff";
+	  {
+	    std::string enc_string=zen_corr_coeff.print_xml();
+	    rv << " length=" << enc_string.size() << " encoding=\"" << xml_encoding_names[zen_corr_coeff.encoding] << "\">" ;
+	    rv << enc_string;
+	  }
+}
+	rv << "</zen_corr_coeff>\n"; 
+	rv << xml_indent() << "<array_az_ellipse>" << array_az_ellipse << "</array_az_ellipse>\n";
+	rv << xml_indent() << "<array_za_ellipse>" << array_za_ellipse << "</array_za_ellipse>\n";
+	rv << xml_indent() << "<array_angle>" << array_angle << "</array_angle>\n";
+	rv << xml_indent() << "<min_vgc>" << min_vgc << "</min_vgc>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void receiver_config::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"s4_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> s4_id;
+	      }
+	    if (extract_xml_record(field,"name",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)255));
+	        name[std::min(in.size(),(size_t)254)]=0;
+	      }
+	    if (extract_xml_record(field,"beam_width",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> beam_width;
+	      }
+	    if (extract_xml_record(field,"center_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> center_freq;
+	      }
+	    if (extract_xml_record(field,"latitude",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> latitude;
+	      }
+	    if (extract_xml_record(field,"longitude",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> longitude;
+	      }
+	    if (extract_xml_record(field,"elevation",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> elevation;
+	      }
+	    if (extract_xml_record(field,"diameter",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> diameter;
+	      }
+	    if (extract_xml_record(field,"az_orientation",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> az_orientation;
+	      }
+	    az_corr_coeff.clear();
+	    if (extract_xml_record(field,"az_corr_coeff",sub)) {
+	      pos=sub.find(">");
+	      do {
+	        if (pos!=std::string::npos) {
+	          do { pos++; } while ((sub[pos]=='\n') || (sub[pos]==','));
+	          std::istringstream in(std::string(sub.c_str()+pos)); 
+	          float tmp;
+	          in >> tmp;
+	          az_corr_coeff.push_back(tmp);
+	        }
+	      } while ((pos=sub.find(",",pos)) != std::string::npos); 
+	    }
+	    zen_corr_coeff.clear();
+	    if (extract_xml_record(field,"zen_corr_coeff",sub)) {
+	      pos=sub.find(">");
+	      do {
+	        if (pos!=std::string::npos) {
+	          do { pos++; } while ((sub[pos]=='\n') || (sub[pos]==','));
+	          std::istringstream in(std::string(sub.c_str()+pos)); 
+	          float tmp;
+	          in >> tmp;
+	          zen_corr_coeff.push_back(tmp);
+	        }
+	      } while ((pos=sub.find(",",pos)) != std::string::npos); 
+	    }
+	    if (extract_xml_record(field,"array_az_ellipse",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> array_az_ellipse;
+	      }
+	    if (extract_xml_record(field,"array_za_ellipse",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> array_za_ellipse;
+	      }
+	    if (extract_xml_record(field,"array_angle",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> array_angle;
+	      }
+	    if (extract_xml_record(field,"min_vgc",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_vgc;
+	      }
+	      }
+	      }
+
+	void receiver_config::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> s4_id;
+	    }
+	  {  
+	        strncpy(name,s[2]->c_str(),255);
+	        name[254]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> beam_width;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> center_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> latitude;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> longitude;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> elevation;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> diameter;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> az_orientation;
+	    }
+	  {  
+	  std::string::size_type p,q;
+	  int i;
+	    az_corr_coeff.clear();
+	      SQL_ROW tmp(s[10]); 
+	        for (i=0;i<tmp.argc();i++) {
+	          std::istringstream in(*(tmp[i]));
+	          float tmp0;
+	          in >> tmp0;
+	          az_corr_coeff.push_back(tmp0);
+	      }
+	    }
+	  {  
+	  std::string::size_type p,q;
+	  int i;
+	    zen_corr_coeff.clear();
+	      SQL_ROW tmp(s[11]); 
+	        for (i=0;i<tmp.argc();i++) {
+	          std::istringstream in(*(tmp[i]));
+	          float tmp0;
+	          in >> tmp0;
+	          zen_corr_coeff.push_back(tmp0);
+	      }
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> array_az_ellipse;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> array_za_ellipse;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> array_angle;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> min_vgc;
+	    }
+	      }
+
+	void receiver_config::parse(const std::string &s) {
+	      SQL_ROW row(&s,16);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<recorder_config>::table_name="recorder_config";
 template <> const char * db_table<recorder_config>::_search_tag=table_name;
 template <> const int db_table<recorder_config>::_nfields=6;
-template <> const char * const db_table<recorder_config>::column_names[6]= {"id","name","bits_per_sample","sample_rate","beams","version"};
-
-recorder_config::recorder_config() :
-    db_table<recorder_config>(*this,-1),
-    id(0),
-    bits_per_sample(0),
-    sample_rate(0),
-    beams(0),
-    version(0) {
-    db_open();
-    name[0]=0;
+template <> const char * const db_table<recorder_config>::column_names[6]={"id","name","bits_per_sample","sample_rate","beams","version"};
+
+recorder_config::recorder_config() : 
+	db_table<recorder_config>(*this,-1),
+	id(0),
+	bits_per_sample(0),
+	sample_rate(0),
+	beams(0),
+	version(0)
+{
+	db_open();
+	name[0]=0;
 }
 
 
-recorder_config::recorder_config(const recorder_config &a) :
-    db_table<recorder_config>(*this,-1),
-    id(a.id),
-    bits_per_sample(a.bits_per_sample),
-    sample_rate(a.sample_rate),
-    beams(a.beams),
-    version(a.version) {
-    db_open();
-    strcpy(name,a.name);
+recorder_config::recorder_config(const recorder_config &a) : 
+	db_table<recorder_config>(*this,-1),
+	id(a.id),
+	bits_per_sample(a.bits_per_sample),
+	sample_rate(a.sample_rate),
+	beams(a.beams),
+	version(a.version)
+{
+	db_open();
+	strcpy(name,a.name);
 }
 
 
-recorder_config::recorder_config(const SQL_ROW &a) :
-    db_table<recorder_config>(*this,-1) {
-    db_open();
-    parse(a);
+recorder_config::recorder_config(const SQL_ROW &a) : 
+	db_table<recorder_config>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-recorder_config::recorder_config(const std::string &s,const char *tag) :
-    db_table<recorder_config>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+recorder_config::recorder_config(const std::string &s,const char *tag) : 
+	db_table<recorder_config>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
 recorder_config &recorder_config::operator =(const recorder_config &a) {
-    if (&a != this) {
-        id=a.id;
-        bits_per_sample=a.bits_per_sample;
-        sample_rate=a.sample_rate;
-        beams=a.beams;
-        version=a.version;
-        strcpy(name,a.name);
-    }
-    return (*this);
-}
-
-
-std::string recorder_config::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<6; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string recorder_config::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string recorder_config::select_format() const {
-    std::string rv("");
-    for (int i=0; i<5; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string recorder_config::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << "'" << name << "'";
-    rv << ',';
-    rv << bits_per_sample;
-    rv << ',';
-    rv << sample_rate;
-    rv << ',';
-    rv << beams;
-    rv << ',';
-    rv << version;
-    return rv.str();
-}
-
-
-std::string recorder_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    {
-        std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
-        rv << xml_indent() << "<name>";
-        rv << enc_field << "</name>\n";
-    }
-    rv << xml_indent() << "<bits_per_sample>" << bits_per_sample << "</bits_per_sample>\n";
-    rv << xml_indent() << "<sample_rate>" << sample_rate << "</sample_rate>\n";
-    rv << xml_indent() << "<beams>" << beams << "</beams>\n";
-    rv << xml_indent() << "<version>" << version << "</version>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void recorder_config::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"name",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
-            name[std::min(in.size(),(size_t)63)]=0;
-        }
-        if (extract_xml_record(field,"bits_per_sample",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> bits_per_sample;
-        }
-        if (extract_xml_record(field,"sample_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> sample_rate;
-        }
-        if (extract_xml_record(field,"beams",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> beams;
-        }
-        if (extract_xml_record(field,"version",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> version;
-        }
-    }
-}
-
-void recorder_config::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        strncpy(name,s[1]->c_str(),64);
-        name[63]=0;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> bits_per_sample;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> sample_rate;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> beams;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> version;
-    }
-}
-
-void recorder_config::parse(const std::string &s) {
-    SQL_ROW row(&s,6);
-    parse(row);
+	if (&a != this) {
+		id=a.id;
+		bits_per_sample=a.bits_per_sample;
+		sample_rate=a.sample_rate;
+		beams=a.beams;
+		version=a.version;
+	strcpy(name,a.name);
+	}
+	return (*this);
 }
 
-template <> const char * const db_table<splitter_config>::table_name="splitter_config";
-template <> const char * db_table<splitter_config>::_search_tag=table_name;
-template <> const int db_table<splitter_config>::_nfields=12;
-template <> const char * const db_table<splitter_config>::column_names[12]= {"id","version","data_type","fft_len","ifft_len","filter","window","samples_per_wu","highpass","blanker_filter","pfb_ntaps","pfb_width_factor"};
-
-splitter_config::splitter_config() :
-    db_table<splitter_config>(*this,-1),
-    id(0),
-    version(0),
-    fft_len(0),
-    ifft_len(0),
-    samples_per_wu(0),
-    highpass(0),
-    pfb_ntaps(0),
-    pfb_width_factor(0) {
-    db_open();
-    data_type[0]=0;
-    filter[0]=0;
-    window[0]=0;
-    blanker_filter[0]=0;
-}
-
-
-splitter_config::splitter_config(const splitter_config &a) :
-    db_table<splitter_config>(*this,-1),
-    id(a.id),
-    version(a.version),
-    fft_len(a.fft_len),
-    ifft_len(a.ifft_len),
-    samples_per_wu(a.samples_per_wu),
-    highpass(a.highpass),
-    pfb_ntaps(a.pfb_ntaps),
-    pfb_width_factor(a.pfb_width_factor) {
-    db_open();
-    strcpy(data_type,a.data_type);
-    strcpy(filter,a.filter);
-    strcpy(window,a.window);
-    strcpy(blanker_filter,a.blanker_filter);
-}
-
-
-splitter_config::splitter_config(const SQL_ROW &a) :
-    db_table<splitter_config>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-splitter_config::splitter_config(const std::string &s,const char *tag) :
-    db_table<splitter_config>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+
+std::string recorder_config::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<6;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-splitter_config &splitter_config::operator =(const splitter_config &a) {
-    if (&a != this) {
-        id=a.id;
-        version=a.version;
-        fft_len=a.fft_len;
-        ifft_len=a.ifft_len;
-        samples_per_wu=a.samples_per_wu;
-        highpass=a.highpass;
-        pfb_ntaps=a.pfb_ntaps;
-        pfb_width_factor=a.pfb_width_factor;
-        strcpy(data_type,a.data_type);
-        strcpy(filter,a.filter);
-        strcpy(window,a.window);
-        strcpy(blanker_filter,a.blanker_filter);
-    }
-    return (*this);
-}
-
-
-std::string splitter_config::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<12; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string splitter_config::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string splitter_config::select_format() const {
-    std::string rv("");
-    for (int i=0; i<11; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string splitter_config::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << version;
-    rv << ',';
-    rv << "'" << data_type << "'";
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << ifft_len;
-    rv << ',';
-    rv << "'" << filter << "'";
-    rv << ',';
-    rv << "'" << window << "'";
-    rv << ',';
-    rv << samples_per_wu;
-    rv << ',';
-    rv << highpass;
-    rv << ',';
-    rv << "'" << blanker_filter << "'";
-    rv << ',';
-    rv << pfb_ntaps;
-    rv << ',';
-    rv << pfb_width_factor;
-    return rv.str();
-}
-
-
-std::string splitter_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<version>" << version << "</version>\n";
-    {
-        std::string enc_field=xml_encode_string(data_type,std::min(strlen(data_type),sizeof(data_type)));
-        rv << xml_indent() << "<data_type>";
-        rv << enc_field << "</data_type>\n";
-    }
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<ifft_len>" << ifft_len << "</ifft_len>\n";
-    {
-        std::string enc_field=xml_encode_string(filter,std::min(strlen(filter),sizeof(filter)));
-        rv << xml_indent() << "<filter>";
-        rv << enc_field << "</filter>\n";
-    }
-    {
-        std::string enc_field=xml_encode_string(window,std::min(strlen(window),sizeof(window)));
-        rv << xml_indent() << "<window>";
-        rv << enc_field << "</window>\n";
-    }
-    rv << xml_indent() << "<samples_per_wu>" << samples_per_wu << "</samples_per_wu>\n";
-    rv << xml_indent() << "<highpass>" << highpass << "</highpass>\n";
-    {
-        std::string enc_field=xml_encode_string(blanker_filter,std::min(strlen(blanker_filter),sizeof(blanker_filter)));
-        rv << xml_indent() << "<blanker_filter>";
-        rv << enc_field << "</blanker_filter>\n";
-    }
-    rv << xml_indent() << "<pfb_ntaps>" << pfb_ntaps << "</pfb_ntaps>\n";
-    rv << xml_indent() << "<pfb_width_factor>" << pfb_width_factor << "</pfb_width_factor>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void splitter_config::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"version",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> version;
-        }
-        if (extract_xml_record(field,"data_type",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(data_type,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
-            data_type[std::min(in.size(),(size_t)63)]=0;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"ifft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ifft_len;
-        }
-        if (extract_xml_record(field,"filter",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(filter,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
-            filter[std::min(in.size(),(size_t)63)]=0;
-        }
-        if (extract_xml_record(field,"window",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(window,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
-            window[std::min(in.size(),(size_t)63)]=0;
-        }
-        if (extract_xml_record(field,"samples_per_wu",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> samples_per_wu;
-        }
-        if (extract_xml_record(field,"highpass",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> highpass;
-        }
-        if (extract_xml_record(field,"blanker_filter",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(blanker_filter,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
-            blanker_filter[std::min(in.size(),(size_t)63)]=0;
-        }
-        if (extract_xml_record(field,"pfb_ntaps",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pfb_ntaps;
-        }
-        if (extract_xml_record(field,"pfb_width_factor",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pfb_width_factor;
-        }
-    }
-}
-
-void splitter_config::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> version;
-    }
-    {
-        strncpy(data_type,s[2]->c_str(),64);
-        data_type[63]=0;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> ifft_len;
-    }
-    {
-        strncpy(filter,s[5]->c_str(),64);
-        filter[63]=0;
-    }
-    {
-        strncpy(window,s[6]->c_str(),64);
-        window[63]=0;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> samples_per_wu;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> highpass;
-    }
-    {
-        strncpy(blanker_filter,s[9]->c_str(),64);
-        blanker_filter[63]=0;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> pfb_ntaps;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> pfb_width_factor;
-    }
-}
-
-void splitter_config::parse(const std::string &s) {
-    SQL_ROW row(&s,12);
-    parse(row);
+std::string recorder_config::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
-template <> const char * const db_table<analysis_config>::table_name="analysis_config";
-template <> const char * db_table<analysis_config>::_search_tag=table_name;
-template <> const int db_table<analysis_config>::_nfields=39;
-template <> const char * const db_table<analysis_config>::column_names[39]= {"id","spike_thresh","spikes_per_spectrum","autocorr_thresh","autocorr_per_spectrum","autocorr_fftlen","gauss_null_chi_sq_thresh","gauss_chi_sq_thresh","gauss_power_thresh","gauss_peak_power_thresh","gauss_pot_length","pulse_thresh","pulse_display_thresh","pulse_max","pulse_min","pulse_fft_max","pulse_pot_length","triplet_thresh","triplet_max","triplet_min","triplet_pot_length","pot_overlap_factor","pot_t_offset" [...]
-
-analysis_config::analysis_config() :
-    db_table<analysis_config>(*this,-1),
-    id(0),
-    spike_thresh(0),
-    spikes_per_spectrum(0),
-    autocorr_thresh(0),
-    autocorr_per_spectrum(0),
-    autocorr_fftlen(0),
-    gauss_null_chi_sq_thresh(0),
-    gauss_chi_sq_thresh(0),
-    gauss_power_thresh(0),
-    gauss_peak_power_thresh(0),
-    gauss_pot_length(0),
-    pulse_thresh(0),
-    pulse_display_thresh(0),
-    pulse_max(0),
-    pulse_min(0),
-    pulse_fft_max(0),
-    pulse_pot_length(0),
-    triplet_thresh(0),
-    triplet_max(0),
-    triplet_min(0),
-    triplet_pot_length(0),
-    pot_overlap_factor(0),
-    pot_t_offset(0),
-    pot_min_slew(0),
-    pot_max_slew(0),
-    chirp_resolution(0),
-    analysis_fft_lengths(0),
-    bsmooth_boxcar_length(0),
-    bsmooth_chunk_size(0),
-    chirps((chirp_parameter_t *)0,0,_x_xml_values),
-    pulse_beams(0),
-    max_signals(0),
-    max_spikes(0),
-    max_autocorr(0),
-    max_gaussians(0),
-    max_pulses(0),
-    max_triplets(0),
-    keyuniq(0),
-    credit_rate(0) {
-    db_open();
-}
-
-
-analysis_config::analysis_config(const analysis_config &a) :
-    db_table<analysis_config>(*this,-1),
-    id(a.id),
-    spike_thresh(a.spike_thresh),
-    spikes_per_spectrum(a.spikes_per_spectrum),
-    autocorr_thresh(a.autocorr_thresh),
-    autocorr_per_spectrum(a.autocorr_per_spectrum),
-    autocorr_fftlen(a.autocorr_fftlen),
-    gauss_null_chi_sq_thresh(a.gauss_null_chi_sq_thresh),
-    gauss_chi_sq_thresh(a.gauss_chi_sq_thresh),
-    gauss_power_thresh(a.gauss_power_thresh),
-    gauss_peak_power_thresh(a.gauss_peak_power_thresh),
-    gauss_pot_length(a.gauss_pot_length),
-    pulse_thresh(a.pulse_thresh),
-    pulse_display_thresh(a.pulse_display_thresh),
-    pulse_max(a.pulse_max),
-    pulse_min(a.pulse_min),
-    pulse_fft_max(a.pulse_fft_max),
-    pulse_pot_length(a.pulse_pot_length),
-    triplet_thresh(a.triplet_thresh),
-    triplet_max(a.triplet_max),
-    triplet_min(a.triplet_min),
-    triplet_pot_length(a.triplet_pot_length),
-    pot_overlap_factor(a.pot_overlap_factor),
-    pot_t_offset(a.pot_t_offset),
-    pot_min_slew(a.pot_min_slew),
-    pot_max_slew(a.pot_max_slew),
-    chirp_resolution(a.chirp_resolution),
-    analysis_fft_lengths(a.analysis_fft_lengths),
-    bsmooth_boxcar_length(a.bsmooth_boxcar_length),
-    bsmooth_chunk_size(a.bsmooth_chunk_size),
-    chirps(a.chirps),
-    pulse_beams(a.pulse_beams),
-    max_signals(a.max_signals),
-    max_spikes(a.max_spikes),
-    max_autocorr(a.max_autocorr),
-    max_gaussians(a.max_gaussians),
-    max_pulses(a.max_pulses),
-    max_triplets(a.max_triplets),
-    keyuniq(a.keyuniq),
-    credit_rate(a.credit_rate) {
-    db_open();
-}
-
-
-analysis_config::analysis_config(const SQL_ROW &a) :
-    db_table<analysis_config>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-analysis_config::analysis_config(const std::string &s,const char *tag) :
-    db_table<analysis_config>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+std::string recorder_config::select_format() const
+{
+std::string rv("");
+for (int i=0; i<5;i++) rv+="?,";
+rv+="?";
+return rv;
 }
 
+std::string recorder_config::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
 
-analysis_config &analysis_config::operator =(const analysis_config &a) {
-    if (&a != this) {
-        id=a.id;
-        spike_thresh=a.spike_thresh;
-        spikes_per_spectrum=a.spikes_per_spectrum;
-        autocorr_thresh=a.autocorr_thresh;
-        autocorr_per_spectrum=a.autocorr_per_spectrum;
-        autocorr_fftlen=a.autocorr_fftlen;
-        gauss_null_chi_sq_thresh=a.gauss_null_chi_sq_thresh;
-        gauss_chi_sq_thresh=a.gauss_chi_sq_thresh;
-        gauss_power_thresh=a.gauss_power_thresh;
-        gauss_peak_power_thresh=a.gauss_peak_power_thresh;
-        gauss_pot_length=a.gauss_pot_length;
-        pulse_thresh=a.pulse_thresh;
-        pulse_display_thresh=a.pulse_display_thresh;
-        pulse_max=a.pulse_max;
-        pulse_min=a.pulse_min;
-        pulse_fft_max=a.pulse_fft_max;
-        pulse_pot_length=a.pulse_pot_length;
-        triplet_thresh=a.triplet_thresh;
-        triplet_max=a.triplet_max;
-        triplet_min=a.triplet_min;
-        triplet_pot_length=a.triplet_pot_length;
-        pot_overlap_factor=a.pot_overlap_factor;
-        pot_t_offset=a.pot_t_offset;
-        pot_min_slew=a.pot_min_slew;
-        pot_max_slew=a.pot_max_slew;
-        chirp_resolution=a.chirp_resolution;
-        analysis_fft_lengths=a.analysis_fft_lengths;
-        bsmooth_boxcar_length=a.bsmooth_boxcar_length;
-        bsmooth_chunk_size=a.bsmooth_chunk_size;
-        {
-            chirps.clear();
-            std::vector<chirp_parameter_t>::const_iterator i(a.chirps.begin());
-            for (; i!=a.chirps.end(); i++) {
-                chirps.push_back(*i);
-            }
-        }
-        pulse_beams=a.pulse_beams;
-        max_signals=a.max_signals;
-        max_spikes=a.max_spikes;
-        max_autocorr=a.max_autocorr;
-        max_gaussians=a.max_gaussians;
-        max_pulses=a.max_pulses;
-        max_triplets=a.max_triplets;
-        keyuniq=a.keyuniq;
-        credit_rate=a.credit_rate;
-    }
-    return (*this);
-}
-
-
-std::string analysis_config::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<39; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string analysis_config::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string analysis_config::select_format() const {
-    std::string rv("");
-    for (int i=0; i<38; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string analysis_config::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << spike_thresh;
-    rv << ',';
-    rv << spikes_per_spectrum;
-    rv << ',';
-    rv << autocorr_thresh;
-    rv << ',';
-    rv << autocorr_per_spectrum;
-    rv << ',';
-    rv << autocorr_fftlen;
-    rv << ',';
-    rv << gauss_null_chi_sq_thresh;
-    rv << ',';
-    rv << gauss_chi_sq_thresh;
-    rv << ',';
-    rv << gauss_power_thresh;
-    rv << ',';
-    rv << gauss_peak_power_thresh;
-    rv << ',';
-    rv << gauss_pot_length;
-    rv << ',';
-    rv << pulse_thresh;
-    rv << ',';
-    rv << pulse_display_thresh;
-    rv << ',';
-    rv << pulse_max;
-    rv << ',';
-    rv << pulse_min;
-    rv << ',';
-    rv << pulse_fft_max;
-    rv << ',';
-    rv << pulse_pot_length;
-    rv << ',';
-    rv << triplet_thresh;
-    rv << ',';
-    rv << triplet_max;
-    rv << ',';
-    rv << triplet_min;
-    rv << ',';
-    rv << triplet_pot_length;
-    rv << ',';
-    rv << pot_overlap_factor;
-    rv << ',';
-    rv << pot_t_offset;
-    rv << ',';
-    rv << pot_min_slew;
-    rv << ',';
-    rv << pot_max_slew;
-    rv << ',';
-    rv << chirp_resolution;
-    rv << ',';
-    rv << analysis_fft_lengths;
-    rv << ',';
-    rv << bsmooth_boxcar_length;
-    rv << ',';
-    rv << bsmooth_chunk_size;
-    rv << ',';
-    rv << "LIST {";
-    {
-        std::vector<chirp_parameter_t>::const_iterator p=chirps.begin();
-        for (; p<chirps.end(); p++) {
-            rv << p->print();
-            if (p != chirps.end()-1) {
-                rv << ',';
-            } else {
-                rv << "}";
-            }
-        }
-    }
-    rv << ',';
-    rv << pulse_beams;
-    rv << ',';
-    rv << max_signals;
-    rv << ',';
-    rv << max_spikes;
-    rv << ',';
-    rv << max_autocorr;
-    rv << ',';
-    rv << max_gaussians;
-    rv << ',';
-    rv << max_pulses;
-    rv << ',';
-    rv << max_triplets;
-    rv << ',';
-    rv << keyuniq;
-    rv << ',';
-    rv << credit_rate;
-    return rv.str();
-}
-
-
-std::string analysis_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<spike_thresh>" << spike_thresh << "</spike_thresh>\n";
-    rv << xml_indent() << "<spikes_per_spectrum>" << spikes_per_spectrum << "</spikes_per_spectrum>\n";
-    rv << xml_indent() << "<autocorr_thresh>" << autocorr_thresh << "</autocorr_thresh>\n";
-    rv << xml_indent() << "<autocorr_per_spectrum>" << autocorr_per_spectrum << "</autocorr_per_spectrum>\n";
-    rv << xml_indent() << "<autocorr_fftlen>" << autocorr_fftlen << "</autocorr_fftlen>\n";
-    rv << xml_indent() << "<gauss_null_chi_sq_thresh>" << gauss_null_chi_sq_thresh << "</gauss_null_chi_sq_thresh>\n";
-    rv << xml_indent() << "<gauss_chi_sq_thresh>" << gauss_chi_sq_thresh << "</gauss_chi_sq_thresh>\n";
-    rv << xml_indent() << "<gauss_power_thresh>" << gauss_power_thresh << "</gauss_power_thresh>\n";
-    rv << xml_indent() << "<gauss_peak_power_thresh>" << gauss_peak_power_thresh << "</gauss_peak_power_thresh>\n";
-    rv << xml_indent() << "<gauss_pot_length>" << gauss_pot_length << "</gauss_pot_length>\n";
-    rv << xml_indent() << "<pulse_thresh>" << pulse_thresh << "</pulse_thresh>\n";
-    rv << xml_indent() << "<pulse_display_thresh>" << pulse_display_thresh << "</pulse_display_thresh>\n";
-    rv << xml_indent() << "<pulse_max>" << pulse_max << "</pulse_max>\n";
-    rv << xml_indent() << "<pulse_min>" << pulse_min << "</pulse_min>\n";
-    rv << xml_indent() << "<pulse_fft_max>" << pulse_fft_max << "</pulse_fft_max>\n";
-    rv << xml_indent() << "<pulse_pot_length>" << pulse_pot_length << "</pulse_pot_length>\n";
-    rv << xml_indent() << "<triplet_thresh>" << triplet_thresh << "</triplet_thresh>\n";
-    rv << xml_indent() << "<triplet_max>" << triplet_max << "</triplet_max>\n";
-    rv << xml_indent() << "<triplet_min>" << triplet_min << "</triplet_min>\n";
-    rv << xml_indent() << "<triplet_pot_length>" << triplet_pot_length << "</triplet_pot_length>\n";
-    rv << xml_indent() << "<pot_overlap_factor>" << pot_overlap_factor << "</pot_overlap_factor>\n";
-    rv << xml_indent() << "<pot_t_offset>" << pot_t_offset << "</pot_t_offset>\n";
-    rv << xml_indent() << "<pot_min_slew>" << pot_min_slew << "</pot_min_slew>\n";
-    rv << xml_indent() << "<pot_max_slew>" << pot_max_slew << "</pot_max_slew>\n";
-    rv << xml_indent() << "<chirp_resolution>" << chirp_resolution << "</chirp_resolution>\n";
-    rv << xml_indent() << "<analysis_fft_lengths>" << analysis_fft_lengths << "</analysis_fft_lengths>\n";
-    rv << xml_indent() << "<bsmooth_boxcar_length>" << bsmooth_boxcar_length << "</bsmooth_boxcar_length>\n";
-    rv << xml_indent() << "<bsmooth_chunk_size>" << bsmooth_chunk_size << "</bsmooth_chunk_size>\n";
-    if (chirps.size()) {
-        rv << xml_indent() << "<chirps";
-        {
-            std::string enc_string=chirps.print_xml();
-            rv << ">\n" ;
-            rv << enc_string;
-        }
-    }
-    rv << xml_indent(-2);
-    rv << "</chirps>\n";
-    rv << xml_indent() << "<pulse_beams>" << pulse_beams << "</pulse_beams>\n";
-    rv << xml_indent() << "<max_signals>" << max_signals << "</max_signals>\n";
-    rv << xml_indent() << "<max_spikes>" << max_spikes << "</max_spikes>\n";
-    rv << xml_indent() << "<max_autocorr>" << max_autocorr << "</max_autocorr>\n";
-    rv << xml_indent() << "<max_gaussians>" << max_gaussians << "</max_gaussians>\n";
-    rv << xml_indent() << "<max_pulses>" << max_pulses << "</max_pulses>\n";
-    rv << xml_indent() << "<max_triplets>" << max_triplets << "</max_triplets>\n";
-    rv << xml_indent() << "<keyuniq>" << keyuniq << "</keyuniq>\n";
-    rv << xml_indent() << "<credit_rate>" << credit_rate << "</credit_rate>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void analysis_config::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"spike_thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spike_thresh;
-        }
-        if (extract_xml_record(field,"spikes_per_spectrum",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spikes_per_spectrum;
-        }
-        if (extract_xml_record(field,"autocorr_thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> autocorr_thresh;
-        }
-        if (extract_xml_record(field,"autocorr_per_spectrum",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> autocorr_per_spectrum;
-        }
-        if (extract_xml_record(field,"autocorr_fftlen",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> autocorr_fftlen;
-        }
-        if (extract_xml_record(field,"gauss_null_chi_sq_thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gauss_null_chi_sq_thresh;
-        }
-        if (extract_xml_record(field,"gauss_chi_sq_thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gauss_chi_sq_thresh;
-        }
-        if (extract_xml_record(field,"gauss_power_thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gauss_power_thresh;
-        }
-        if (extract_xml_record(field,"gauss_peak_power_thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gauss_peak_power_thresh;
-        }
-        if (extract_xml_record(field,"gauss_pot_length",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gauss_pot_length;
-        }
-        if (extract_xml_record(field,"pulse_thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_thresh;
-        }
-        if (extract_xml_record(field,"pulse_display_thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_display_thresh;
-        }
-        if (extract_xml_record(field,"pulse_max",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_max;
-        }
-        if (extract_xml_record(field,"pulse_min",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_min;
-        }
-        if (extract_xml_record(field,"pulse_fft_max",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_fft_max;
-        }
-        if (extract_xml_record(field,"pulse_pot_length",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_pot_length;
-        }
-        if (extract_xml_record(field,"triplet_thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_thresh;
-        }
-        if (extract_xml_record(field,"triplet_max",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_max;
-        }
-        if (extract_xml_record(field,"triplet_min",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_min;
-        }
-        if (extract_xml_record(field,"triplet_pot_length",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_pot_length;
-        }
-        if (extract_xml_record(field,"pot_overlap_factor",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pot_overlap_factor;
-        }
-        if (extract_xml_record(field,"pot_t_offset",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pot_t_offset;
-        }
-        if (extract_xml_record(field,"pot_min_slew",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pot_min_slew;
-        }
-        if (extract_xml_record(field,"pot_max_slew",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pot_max_slew;
-        }
-        if (extract_xml_record(field,"chirp_resolution",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_resolution;
-        }
-        if (extract_xml_record(field,"analysis_fft_lengths",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> analysis_fft_lengths;
-        }
-        if (extract_xml_record(field,"bsmooth_boxcar_length",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> bsmooth_boxcar_length;
-        }
-        if (extract_xml_record(field,"bsmooth_chunk_size",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> bsmooth_chunk_size;
-        }
-        chirps.clear();
-        if (extract_xml_record(field,"chirps",sub)) {
-            pos=0;
-            while ((pos=sub.find("<chirp_parameter_t",pos)) != std::string::npos) {
-                chirps.push_back(chirp_parameter_t(std::string(sub.c_str()+pos)));
-                pos=sub.find("</chirp_parameter_t",pos);
-                pos=sub.find(">",pos);
-            }
-        }
-        if (extract_xml_record(field,"pulse_beams",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_beams;
-        }
-        if (extract_xml_record(field,"max_signals",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_signals;
-        }
-        if (extract_xml_record(field,"max_spikes",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_spikes;
-        }
-        if (extract_xml_record(field,"max_autocorr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_autocorr;
-        }
-        if (extract_xml_record(field,"max_gaussians",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_gaussians;
-        }
-        if (extract_xml_record(field,"max_pulses",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_pulses;
-        }
-        if (extract_xml_record(field,"max_triplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_triplets;
-        }
-        if (extract_xml_record(field,"keyuniq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> keyuniq;
-        }
-        if (extract_xml_record(field,"credit_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> credit_rate;
-        }
-    }
-}
-
-void analysis_config::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> spike_thresh;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> spikes_per_spectrum;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> autocorr_thresh;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> autocorr_per_spectrum;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> autocorr_fftlen;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> gauss_null_chi_sq_thresh;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> gauss_chi_sq_thresh;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> gauss_power_thresh;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> gauss_peak_power_thresh;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> gauss_pot_length;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> pulse_thresh;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> pulse_display_thresh;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> pulse_max;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> pulse_min;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> pulse_fft_max;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> pulse_pot_length;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> triplet_thresh;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> triplet_max;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> triplet_min;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> triplet_pot_length;
-    }
-    {
-        std::istringstream row(*(s[21]));
-        row >> pot_overlap_factor;
-    }
-    {
-        std::istringstream row(*(s[22]));
-        row >> pot_t_offset;
-    }
-    {
-        std::istringstream row(*(s[23]));
-        row >> pot_min_slew;
-    }
-    {
-        std::istringstream row(*(s[24]));
-        row >> pot_max_slew;
-    }
-    {
-        std::istringstream row(*(s[25]));
-        row >> chirp_resolution;
-    }
-    {
-        std::istringstream row(*(s[26]));
-        row >> analysis_fft_lengths;
-    }
-    {
-        std::istringstream row(*(s[27]));
-        row >> bsmooth_boxcar_length;
-    }
-    {
-        std::istringstream row(*(s[28]));
-        row >> bsmooth_chunk_size;
-    }
-    {
-        std::string::size_type p,q;
-        int i;
-        chirps.clear();
-        SQL_ROW tmp(s[29]);
-        for (i=0; i<tmp.argc(); i++) {
-            chirps.push_back(chirp_parameter_t(SQL_ROW(tmp[i])));
-        }
-    }
-    {
-        std::istringstream row(*(s[30]));
-        row >> pulse_beams;
-    }
-    {
-        std::istringstream row(*(s[31]));
-        row >> max_signals;
-    }
-    {
-        std::istringstream row(*(s[32]));
-        row >> max_spikes;
-    }
-    {
-        std::istringstream row(*(s[33]));
-        row >> max_autocorr;
-    }
-    {
-        std::istringstream row(*(s[34]));
-        row >> max_gaussians;
-    }
-    {
-        std::istringstream row(*(s[35]));
-        row >> max_pulses;
-    }
-    {
-        std::istringstream row(*(s[36]));
-        row >> max_triplets;
-    }
-    {
-        std::istringstream row(*(s[37]));
-        row >> keyuniq;
-    }
-    {
-        std::istringstream row(*(s[38]));
-        row >> credit_rate;
-    }
-}
-
-void analysis_config::parse(const std::string &s) {
-    SQL_ROW row(&s,39);
-    parse(row);
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << "'" << name << "'";
+	rv << ',';
+	rv << bits_per_sample;
+	rv << ',';
+	rv << sample_rate;
+	rv << ',';
+	rv << beams;
+	rv << ',';
+	rv << version;
+	return rv.str();
 }
 
-template <> const char * const db_table<science_config>::table_name="science_config";
-template <> const char * db_table<science_config>::_search_tag=table_name;
-template <> const int db_table<science_config>::_nfields=29;
-template <> const char * const db_table<science_config>::column_names[29]= {"id","active","qpix_scheme","qpix_nside","fpix_width","total_bandwidth","freq_uncertainty","fwhm_beamwidth","sky_disc_radius","observable_sky","epoch","bary_chirp_window","bary_freq_window","nonbary_freq_window","spike_obs_duration","spike_obs_interval","gauss_obs_duration","gauss_obs_interval","pulse_obs_duration","pulse_obs_interval","triplet_obs_duration","triplet_obs_interval","min_spike_id","min_autocorr_id" [...]
-
-science_config::science_config() :
-    db_table<science_config>(*this,-1),
-    id(0),
-    active(0),
-    qpix_nside(0),
-    fpix_width(0),
-    total_bandwidth(0),
-    freq_uncertainty(0),
-    fwhm_beamwidth(0),
-    sky_disc_radius(0),
-    observable_sky(0),
-    epoch(0),
-    bary_chirp_window(0),
-    bary_freq_window(0),
-    nonbary_freq_window(0),
-    spike_obs_duration(0),
-    spike_obs_interval(0),
-    gauss_obs_duration(0),
-    gauss_obs_interval(0),
-    pulse_obs_duration(0),
-    pulse_obs_interval(0),
-    triplet_obs_duration(0),
-    triplet_obs_interval(0),
-    min_spike_id(0),
-    min_autocorr_id(0),
-    min_gaussian_id(0),
-    min_pulse_id(0),
-    min_triplet_id(0),
-    min_app_version(0) {
-    db_open();
-    qpix_scheme[0]=0;
-    info_xml[0]=0;
-}
-
-
-science_config::science_config(const science_config &a) :
-    db_table<science_config>(*this,-1),
-    id(a.id),
-    active(a.active),
-    qpix_nside(a.qpix_nside),
-    fpix_width(a.fpix_width),
-    total_bandwidth(a.total_bandwidth),
-    freq_uncertainty(a.freq_uncertainty),
-    fwhm_beamwidth(a.fwhm_beamwidth),
-    sky_disc_radius(a.sky_disc_radius),
-    observable_sky(a.observable_sky),
-    epoch(a.epoch),
-    bary_chirp_window(a.bary_chirp_window),
-    bary_freq_window(a.bary_freq_window),
-    nonbary_freq_window(a.nonbary_freq_window),
-    spike_obs_duration(a.spike_obs_duration),
-    spike_obs_interval(a.spike_obs_interval),
-    gauss_obs_duration(a.gauss_obs_duration),
-    gauss_obs_interval(a.gauss_obs_interval),
-    pulse_obs_duration(a.pulse_obs_duration),
-    pulse_obs_interval(a.pulse_obs_interval),
-    triplet_obs_duration(a.triplet_obs_duration),
-    triplet_obs_interval(a.triplet_obs_interval),
-    min_spike_id(a.min_spike_id),
-    min_autocorr_id(a.min_autocorr_id),
-    min_gaussian_id(a.min_gaussian_id),
-    min_pulse_id(a.min_pulse_id),
-    min_triplet_id(a.min_triplet_id),
-    min_app_version(a.min_app_version) {
-    db_open();
-    strcpy(qpix_scheme,a.qpix_scheme);
-    strcpy(info_xml,a.info_xml);
-}
-
-
-science_config::science_config(const SQL_ROW &a) :
-    db_table<science_config>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-science_config::science_config(const std::string &s,const char *tag) :
-    db_table<science_config>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
-}
 
+std::string recorder_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	{
+	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
+	  rv << xml_indent() << "<name>";
+	  rv << enc_field << "</name>\n";
+	}
+	rv << xml_indent() << "<bits_per_sample>" << bits_per_sample << "</bits_per_sample>\n";
+	rv << xml_indent() << "<sample_rate>" << sample_rate << "</sample_rate>\n";
+	rv << xml_indent() << "<beams>" << beams << "</beams>\n";
+	rv << xml_indent() << "<version>" << version << "</version>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void recorder_config::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"name",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
+	        name[std::min(in.size(),(size_t)63)]=0;
+	      }
+	    if (extract_xml_record(field,"bits_per_sample",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> bits_per_sample;
+	      }
+	    if (extract_xml_record(field,"sample_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> sample_rate;
+	      }
+	    if (extract_xml_record(field,"beams",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> beams;
+	      }
+	    if (extract_xml_record(field,"version",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> version;
+	      }
+	      }
+	      }
+
+	void recorder_config::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        strncpy(name,s[1]->c_str(),64);
+	        name[63]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> bits_per_sample;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> sample_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> beams;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> version;
+	    }
+	      }
+
+	void recorder_config::parse(const std::string &s) {
+	      SQL_ROW row(&s,6);
+	      parse(row);
+	      }
 
-science_config &science_config::operator =(const science_config &a) {
-    if (&a != this) {
-        id=a.id;
-        active=a.active;
-        qpix_nside=a.qpix_nside;
-        fpix_width=a.fpix_width;
-        total_bandwidth=a.total_bandwidth;
-        freq_uncertainty=a.freq_uncertainty;
-        fwhm_beamwidth=a.fwhm_beamwidth;
-        sky_disc_radius=a.sky_disc_radius;
-        observable_sky=a.observable_sky;
-        epoch=a.epoch;
-        bary_chirp_window=a.bary_chirp_window;
-        bary_freq_window=a.bary_freq_window;
-        nonbary_freq_window=a.nonbary_freq_window;
-        spike_obs_duration=a.spike_obs_duration;
-        spike_obs_interval=a.spike_obs_interval;
-        gauss_obs_duration=a.gauss_obs_duration;
-        gauss_obs_interval=a.gauss_obs_interval;
-        pulse_obs_duration=a.pulse_obs_duration;
-        pulse_obs_interval=a.pulse_obs_interval;
-        triplet_obs_duration=a.triplet_obs_duration;
-        triplet_obs_interval=a.triplet_obs_interval;
-        min_spike_id=a.min_spike_id;
-        min_autocorr_id=a.min_autocorr_id;
-        min_gaussian_id=a.min_gaussian_id;
-        min_pulse_id=a.min_pulse_id;
-        min_triplet_id=a.min_triplet_id;
-        min_app_version=a.min_app_version;
-        strcpy(qpix_scheme,a.qpix_scheme);
-        strcpy(info_xml,a.info_xml);
-    }
-    return (*this);
-}
-
-
-std::string science_config::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<29; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string science_config::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string science_config::select_format() const {
-    std::string rv("");
-    for (int i=0; i<28; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string science_config::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << active;
-    rv << ',';
-    rv << "'" << qpix_scheme << "'";
-    rv << ',';
-    rv << qpix_nside;
-    rv << ',';
-    rv << fpix_width;
-    rv << ',';
-    rv << total_bandwidth;
-    rv << ',';
-    rv << freq_uncertainty;
-    rv << ',';
-    rv << fwhm_beamwidth;
-    rv << ',';
-    rv << sky_disc_radius;
-    rv << ',';
-    rv << observable_sky;
-    rv << ',';
-    rv << epoch;
-    rv << ',';
-    rv << bary_chirp_window;
-    rv << ',';
-    rv << bary_freq_window;
-    rv << ',';
-    rv << nonbary_freq_window;
-    rv << ',';
-    rv << spike_obs_duration;
-    rv << ',';
-    rv << spike_obs_interval;
-    rv << ',';
-    rv << gauss_obs_duration;
-    rv << ',';
-    rv << gauss_obs_interval;
-    rv << ',';
-    rv << pulse_obs_duration;
-    rv << ',';
-    rv << pulse_obs_interval;
-    rv << ',';
-    rv << triplet_obs_duration;
-    rv << ',';
-    rv << triplet_obs_interval;
-    rv << ',';
-    rv << min_spike_id;
-    rv << ',';
-    rv << min_autocorr_id;
-    rv << ',';
-    rv << min_gaussian_id;
-    rv << ',';
-    rv << min_pulse_id;
-    rv << ',';
-    rv << min_triplet_id;
-    rv << ',';
-    rv << min_app_version;
-    rv << ',';
-    rv << "'" << info_xml << "'";
-    return rv.str();
-}
-
-
-std::string science_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<active>" << active << "</active>\n";
-    {
-        std::string enc_field=xml_encode_string(qpix_scheme,std::min(strlen(qpix_scheme),sizeof(qpix_scheme)));
-        rv << xml_indent() << "<qpix_scheme>";
-        rv << enc_field << "</qpix_scheme>\n";
-    }
-    rv << xml_indent() << "<qpix_nside>" << qpix_nside << "</qpix_nside>\n";
-    rv << xml_indent() << "<fpix_width>" << fpix_width << "</fpix_width>\n";
-    rv << xml_indent() << "<total_bandwidth>" << total_bandwidth << "</total_bandwidth>\n";
-    rv << xml_indent() << "<freq_uncertainty>" << freq_uncertainty << "</freq_uncertainty>\n";
-    rv << xml_indent() << "<fwhm_beamwidth>" << fwhm_beamwidth << "</fwhm_beamwidth>\n";
-    rv << xml_indent() << "<sky_disc_radius>" << sky_disc_radius << "</sky_disc_radius>\n";
-    rv << xml_indent() << "<observable_sky>" << observable_sky << "</observable_sky>\n";
-    rv << xml_indent() << "<epoch>" << epoch << "</epoch>\n";
-    rv << xml_indent() << "<bary_chirp_window>" << bary_chirp_window << "</bary_chirp_window>\n";
-    rv << xml_indent() << "<bary_freq_window>" << bary_freq_window << "</bary_freq_window>\n";
-    rv << xml_indent() << "<nonbary_freq_window>" << nonbary_freq_window << "</nonbary_freq_window>\n";
-    rv << xml_indent() << "<spike_obs_duration>" << spike_obs_duration << "</spike_obs_duration>\n";
-    rv << xml_indent() << "<spike_obs_interval>" << spike_obs_interval << "</spike_obs_interval>\n";
-    rv << xml_indent() << "<gauss_obs_duration>" << gauss_obs_duration << "</gauss_obs_duration>\n";
-    rv << xml_indent() << "<gauss_obs_interval>" << gauss_obs_interval << "</gauss_obs_interval>\n";
-    rv << xml_indent() << "<pulse_obs_duration>" << pulse_obs_duration << "</pulse_obs_duration>\n";
-    rv << xml_indent() << "<pulse_obs_interval>" << pulse_obs_interval << "</pulse_obs_interval>\n";
-    rv << xml_indent() << "<triplet_obs_duration>" << triplet_obs_duration << "</triplet_obs_duration>\n";
-    rv << xml_indent() << "<triplet_obs_interval>" << triplet_obs_interval << "</triplet_obs_interval>\n";
-    rv << xml_indent() << "<min_spike_id>" << min_spike_id << "</min_spike_id>\n";
-    rv << xml_indent() << "<min_autocorr_id>" << min_autocorr_id << "</min_autocorr_id>\n";
-    rv << xml_indent() << "<min_gaussian_id>" << min_gaussian_id << "</min_gaussian_id>\n";
-    rv << xml_indent() << "<min_pulse_id>" << min_pulse_id << "</min_pulse_id>\n";
-    rv << xml_indent() << "<min_triplet_id>" << min_triplet_id << "</min_triplet_id>\n";
-    rv << xml_indent() << "<min_app_version>" << min_app_version << "</min_app_version>\n";
-    {
-        std::string enc_field=xml_encode_string(info_xml,std::min(strlen(info_xml),sizeof(info_xml)));
-        rv << xml_indent() << "<info_xml>";
-        rv << enc_field << "</info_xml>\n";
-    }
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void science_config::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"active",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> active;
-        }
-        if (extract_xml_record(field,"qpix_scheme",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(qpix_scheme,(const char *)&(in.front()),std::min(in.size(),(size_t)16));
-            qpix_scheme[std::min(in.size(),(size_t)15)]=0;
-        }
-        if (extract_xml_record(field,"qpix_nside",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> qpix_nside;
-        }
-        if (extract_xml_record(field,"fpix_width",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fpix_width;
-        }
-        if (extract_xml_record(field,"total_bandwidth",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> total_bandwidth;
-        }
-        if (extract_xml_record(field,"freq_uncertainty",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq_uncertainty;
-        }
-        if (extract_xml_record(field,"fwhm_beamwidth",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fwhm_beamwidth;
-        }
-        if (extract_xml_record(field,"sky_disc_radius",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> sky_disc_radius;
-        }
-        if (extract_xml_record(field,"observable_sky",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> observable_sky;
-        }
-        if (extract_xml_record(field,"epoch",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> epoch;
-        }
-        if (extract_xml_record(field,"bary_chirp_window",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> bary_chirp_window;
-        }
-        if (extract_xml_record(field,"bary_freq_window",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> bary_freq_window;
-        }
-        if (extract_xml_record(field,"nonbary_freq_window",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> nonbary_freq_window;
-        }
-        if (extract_xml_record(field,"spike_obs_duration",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spike_obs_duration;
-        }
-        if (extract_xml_record(field,"spike_obs_interval",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spike_obs_interval;
-        }
-        if (extract_xml_record(field,"gauss_obs_duration",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gauss_obs_duration;
-        }
-        if (extract_xml_record(field,"gauss_obs_interval",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gauss_obs_interval;
-        }
-        if (extract_xml_record(field,"pulse_obs_duration",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_obs_duration;
-        }
-        if (extract_xml_record(field,"pulse_obs_interval",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_obs_interval;
-        }
-        if (extract_xml_record(field,"triplet_obs_duration",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_obs_duration;
-        }
-        if (extract_xml_record(field,"triplet_obs_interval",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_obs_interval;
-        }
-        if (extract_xml_record(field,"min_spike_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_spike_id;
-        }
-        if (extract_xml_record(field,"min_autocorr_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_autocorr_id;
-        }
-        if (extract_xml_record(field,"min_gaussian_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_gaussian_id;
-        }
-        if (extract_xml_record(field,"min_pulse_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_pulse_id;
-        }
-        if (extract_xml_record(field,"min_triplet_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_triplet_id;
-        }
-        if (extract_xml_record(field,"min_app_version",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_app_version;
-        }
-        if (extract_xml_record(field,"info_xml",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(info_xml,(const char *)&(in.front()),std::min(in.size(),(size_t)255));
-            info_xml[std::min(in.size(),(size_t)254)]=0;
-        }
-    }
-}
-
-void science_config::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> active;
-    }
-    {
-        strncpy(qpix_scheme,s[2]->c_str(),16);
-        qpix_scheme[15]=0;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> qpix_nside;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> fpix_width;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> total_bandwidth;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> freq_uncertainty;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> fwhm_beamwidth;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> sky_disc_radius;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> observable_sky;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> epoch;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> bary_chirp_window;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> bary_freq_window;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> nonbary_freq_window;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> spike_obs_duration;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> spike_obs_interval;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> gauss_obs_duration;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> gauss_obs_interval;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> pulse_obs_duration;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> pulse_obs_interval;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> triplet_obs_duration;
-    }
-    {
-        std::istringstream row(*(s[21]));
-        row >> triplet_obs_interval;
-    }
-    {
-        std::istringstream row(*(s[22]));
-        row >> min_spike_id;
-    }
-    {
-        std::istringstream row(*(s[23]));
-        row >> min_autocorr_id;
-    }
-    {
-        std::istringstream row(*(s[24]));
-        row >> min_gaussian_id;
-    }
-    {
-        std::istringstream row(*(s[25]));
-        row >> min_pulse_id;
-    }
-    {
-        std::istringstream row(*(s[26]));
-        row >> min_triplet_id;
-    }
-    {
-        std::istringstream row(*(s[27]));
-        row >> min_app_version;
-    }
-    {
-        strncpy(info_xml,s[28]->c_str(),255);
-        info_xml[254]=0;
-    }
-}
-
-void science_config::parse(const std::string &s) {
-    SQL_ROW row(&s,29);
-    parse(row);
+template <> const char * const db_table<splitter_config>::table_name="splitter_config";
+template <> const char * db_table<splitter_config>::_search_tag=table_name;
+template <> const int db_table<splitter_config>::_nfields=13;
+template <> const char * const db_table<splitter_config>::column_names[13]={"id","version","data_type","fft_len","ifft_len","filter","window","samples_per_wu","highpass","blanker_filter","pfb_ntaps","pfb_width_factor","wu_bits_per_sample"};
+
+splitter_config::splitter_config() : 
+	db_table<splitter_config>(*this,-1),
+	id(0),
+	version(0),
+	fft_len(0),
+	ifft_len(0),
+	samples_per_wu(0),
+	highpass(0),
+	pfb_ntaps(0),
+	pfb_width_factor(0),
+	wu_bits_per_sample(0)
+{
+	db_open();
+	data_type[0]=0;
+	filter[0]=0;
+	window[0]=0;
+	blanker_filter[0]=0;
+}
+
+
+splitter_config::splitter_config(const splitter_config &a) : 
+	db_table<splitter_config>(*this,-1),
+	id(a.id),
+	version(a.version),
+	fft_len(a.fft_len),
+	ifft_len(a.ifft_len),
+	samples_per_wu(a.samples_per_wu),
+	highpass(a.highpass),
+	pfb_ntaps(a.pfb_ntaps),
+	pfb_width_factor(a.pfb_width_factor),
+	wu_bits_per_sample(a.wu_bits_per_sample)
+{
+	db_open();
+	strcpy(data_type,a.data_type);
+	strcpy(filter,a.filter);
+	strcpy(window,a.window);
+	strcpy(blanker_filter,a.blanker_filter);
 }
 
-template <> const char * const db_type<candidate_t>::type_name="candidate_t";
-template <> const char * db_type<candidate_t>::_search_tag=type_name;
-template <> const int db_type<candidate_t>::_nfields=5;
-template <> const char * const db_type<candidate_t>::column_names[5]= {"type","id","num_obs","score","is_rfi"};
 
-candidate_t::candidate_t() :
-    db_type<candidate_t>(*this),
-    type(0),
-    id(0),
-    num_obs(0),
-    score(0),
-    is_rfi(0) {
-    db_open();
+splitter_config::splitter_config(const SQL_ROW &a) : 
+	db_table<splitter_config>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-candidate_t::candidate_t(const candidate_t &a) :
-    db_type<candidate_t>(*this),
-    type(a.type),
-    id(a.id),
-    num_obs(a.num_obs),
-    score(a.score),
-    is_rfi(a.is_rfi) {
-    db_open();
+splitter_config::splitter_config(const std::string &s,const char *tag) : 
+	db_table<splitter_config>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-candidate_t::candidate_t(const SQL_ROW &a) :
-    db_type<candidate_t>(*this) {
-    db_open();
-    parse(a);
+splitter_config &splitter_config::operator =(const splitter_config &a) {
+	if (&a != this) {
+		id=a.id;
+		version=a.version;
+		fft_len=a.fft_len;
+		ifft_len=a.ifft_len;
+		samples_per_wu=a.samples_per_wu;
+		highpass=a.highpass;
+		pfb_ntaps=a.pfb_ntaps;
+		pfb_width_factor=a.pfb_width_factor;
+		wu_bits_per_sample=a.wu_bits_per_sample;
+	strcpy(data_type,a.data_type);
+	strcpy(filter,a.filter);
+	strcpy(window,a.window);
+	strcpy(blanker_filter,a.blanker_filter);
+	}
+	return (*this);
 }
 
 
-candidate_t::candidate_t(const std::string &s,const char *tag) :
-    db_type<candidate_t>(*this) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+std::string splitter_config::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<13;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-candidate_t &candidate_t::operator =(const candidate_t &a) {
-    if (&a != this) {
-        type=a.type;
-        id=a.id;
-        num_obs=a.num_obs;
-        score=a.score;
-        is_rfi=a.is_rfi;
-    }
-    return (*this);
-}
-
-
-std::string candidate_t::update_format() const {
-    std::ostringstream rv("");
-
-    rv << "ROW(";
-    for (int i=1; i<5; i++) rv << "?,";
-    rv << "?";
-    rv << ")";
-
-    return rv.str();
-}
-
-
-std::string candidate_t::insert_format() const {
-    return update_format();
-}
-
-std::string candidate_t::select_format() const {
-    std::string rv("");
-    for (int i=0; i<4; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string candidate_t::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << "ROW(";
-    rv << type;
-    rv << ',';
-    rv << id;
-    rv << ',';
-    rv << num_obs;
-    rv << ',';
-    rv << score;
-    rv << ',';
-    rv << is_rfi;
-    rv << ")";
-    return rv.str();
-}
-
-
-std::string candidate_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    rv << xml_indent() << "<type>" << type << "</type>\n";
-    rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<num_obs>" << num_obs << "</num_obs>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    rv << xml_indent() << "<is_rfi>" << is_rfi << "</is_rfi>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void candidate_t::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"type",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> type;
-        }
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"num_obs",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_obs;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-        if (extract_xml_record(field,"is_rfi",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> is_rfi;
-        }
-    }
-}
-
-void candidate_t::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> type;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> num_obs;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> score;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> is_rfi;
-    }
-}
-
-void candidate_t::parse(const std::string &s) {
-    SQL_ROW row(&s,5);
-    parse(row);
+std::string splitter_config::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
-template <> const char * const db_table<meta_candidate>::table_name="meta_candidate";
-template <> const char * db_table<meta_candidate>::_search_tag=table_name;
-template <> const int db_table<meta_candidate>::_nfields=32;
-template <> const char * const db_table<meta_candidate>::column_names[32]= {"id","version","time_last_updated","num_spikes","num_spike_b_multiplets","best_spike_b_mp_score","num_spike_nb_multiplets","best_spike_nb_mp_score","spike_high_id","num_gaussians","num_gaussian_b_multiplets","best_gaussian_b_mp_score","num_gaussian_nb_multiplets","best_gaussian_nb_mp_score","gaussian_high_id","num_pulses","num_pulse_b_multiplets","best_pulse_b_mp_score","num_pulse_nb_multiplets","best_pulse_nb_mp [...]
-
-meta_candidate::meta_candidate() :
-    db_table<meta_candidate>(*this,-1),
-    id(0),
-    version(0),
-    time_last_updated(0),
-    num_spikes(0),
-    num_spike_b_multiplets(0),
-    best_spike_b_mp_score(0),
-    num_spike_nb_multiplets(0),
-    best_spike_nb_mp_score(0),
-    spike_high_id(0),
-    num_gaussians(0),
-    num_gaussian_b_multiplets(0),
-    best_gaussian_b_mp_score(0),
-    num_gaussian_nb_multiplets(0),
-    best_gaussian_nb_mp_score(0),
-    gaussian_high_id(0),
-    num_pulses(0),
-    num_pulse_b_multiplets(0),
-    best_pulse_b_mp_score(0),
-    num_pulse_nb_multiplets(0),
-    best_pulse_nb_mp_score(0),
-    pulse_high_id(0),
-    num_triplets(0),
-    num_triplet_b_multiplets(0),
-    best_triplet_b_mp_score(0),
-    num_triplet_nb_multiplets(0),
-    best_triplet_nb_mp_score(0),
-    triplet_high_id(0),
-    num_stars(0),
-    best_star_score(0),
-    meta_score(0),
-    rfi_clean(0),
-    state(0) {
-    db_open();
-}
-
-
-meta_candidate::meta_candidate(const meta_candidate &a) :
-    db_table<meta_candidate>(*this,-1),
-    id(a.id),
-    version(a.version),
-    time_last_updated(a.time_last_updated),
-    num_spikes(a.num_spikes),
-    num_spike_b_multiplets(a.num_spike_b_multiplets),
-    best_spike_b_mp_score(a.best_spike_b_mp_score),
-    num_spike_nb_multiplets(a.num_spike_nb_multiplets),
-    best_spike_nb_mp_score(a.best_spike_nb_mp_score),
-    spike_high_id(a.spike_high_id),
-    num_gaussians(a.num_gaussians),
-    num_gaussian_b_multiplets(a.num_gaussian_b_multiplets),
-    best_gaussian_b_mp_score(a.best_gaussian_b_mp_score),
-    num_gaussian_nb_multiplets(a.num_gaussian_nb_multiplets),
-    best_gaussian_nb_mp_score(a.best_gaussian_nb_mp_score),
-    gaussian_high_id(a.gaussian_high_id),
-    num_pulses(a.num_pulses),
-    num_pulse_b_multiplets(a.num_pulse_b_multiplets),
-    best_pulse_b_mp_score(a.best_pulse_b_mp_score),
-    num_pulse_nb_multiplets(a.num_pulse_nb_multiplets),
-    best_pulse_nb_mp_score(a.best_pulse_nb_mp_score),
-    pulse_high_id(a.pulse_high_id),
-    num_triplets(a.num_triplets),
-    num_triplet_b_multiplets(a.num_triplet_b_multiplets),
-    best_triplet_b_mp_score(a.best_triplet_b_mp_score),
-    num_triplet_nb_multiplets(a.num_triplet_nb_multiplets),
-    best_triplet_nb_mp_score(a.best_triplet_nb_mp_score),
-    triplet_high_id(a.triplet_high_id),
-    num_stars(a.num_stars),
-    best_star_score(a.best_star_score),
-    meta_score(a.meta_score),
-    rfi_clean(a.rfi_clean),
-    state(a.state) {
-    db_open();
-}
-
-
-meta_candidate::meta_candidate(const SQL_ROW &a) :
-    db_table<meta_candidate>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-meta_candidate::meta_candidate(const std::string &s,const char *tag) :
-    db_table<meta_candidate>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+std::string splitter_config::select_format() const
+{
+std::string rv("");
+for (int i=0; i<12;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string splitter_config::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << version;
+	rv << ',';
+	rv << "'" << data_type << "'";
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << ifft_len;
+	rv << ',';
+	rv << "'" << filter << "'";
+	rv << ',';
+	rv << "'" << window << "'";
+	rv << ',';
+	rv << samples_per_wu;
+	rv << ',';
+	rv << highpass;
+	rv << ',';
+	rv << "'" << blanker_filter << "'";
+	rv << ',';
+	rv << pfb_ntaps;
+	rv << ',';
+	rv << pfb_width_factor;
+	rv << ',';
+	rv << wu_bits_per_sample;
+	return rv.str();
+}
+
+
+std::string splitter_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<version>" << version << "</version>\n";
+	{
+	  std::string enc_field=xml_encode_string(data_type,std::min(strlen(data_type),sizeof(data_type)));
+	  rv << xml_indent() << "<data_type>";
+	  rv << enc_field << "</data_type>\n";
+	}
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<ifft_len>" << ifft_len << "</ifft_len>\n";
+	{
+	  std::string enc_field=xml_encode_string(filter,std::min(strlen(filter),sizeof(filter)));
+	  rv << xml_indent() << "<filter>";
+	  rv << enc_field << "</filter>\n";
+	}
+	{
+	  std::string enc_field=xml_encode_string(window,std::min(strlen(window),sizeof(window)));
+	  rv << xml_indent() << "<window>";
+	  rv << enc_field << "</window>\n";
+	}
+	rv << xml_indent() << "<samples_per_wu>" << samples_per_wu << "</samples_per_wu>\n";
+	rv << xml_indent() << "<highpass>" << highpass << "</highpass>\n";
+	{
+	  std::string enc_field=xml_encode_string(blanker_filter,std::min(strlen(blanker_filter),sizeof(blanker_filter)));
+	  rv << xml_indent() << "<blanker_filter>";
+	  rv << enc_field << "</blanker_filter>\n";
+	}
+	rv << xml_indent() << "<pfb_ntaps>" << pfb_ntaps << "</pfb_ntaps>\n";
+	rv << xml_indent() << "<pfb_width_factor>" << pfb_width_factor << "</pfb_width_factor>\n";
+	rv << xml_indent() << "<wu_bits_per_sample>" << wu_bits_per_sample << "</wu_bits_per_sample>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void splitter_config::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"version",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> version;
+	      }
+	    if (extract_xml_record(field,"data_type",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(data_type,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
+	        data_type[std::min(in.size(),(size_t)63)]=0;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"ifft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ifft_len;
+	      }
+	    if (extract_xml_record(field,"filter",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(filter,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
+	        filter[std::min(in.size(),(size_t)63)]=0;
+	      }
+	    if (extract_xml_record(field,"window",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(window,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
+	        window[std::min(in.size(),(size_t)63)]=0;
+	      }
+	    if (extract_xml_record(field,"samples_per_wu",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> samples_per_wu;
+	      }
+	    if (extract_xml_record(field,"highpass",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> highpass;
+	      }
+	    if (extract_xml_record(field,"blanker_filter",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(blanker_filter,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
+	        blanker_filter[std::min(in.size(),(size_t)63)]=0;
+	      }
+	    if (extract_xml_record(field,"pfb_ntaps",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pfb_ntaps;
+	      }
+	    if (extract_xml_record(field,"pfb_width_factor",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pfb_width_factor;
+	      }
+	    if (extract_xml_record(field,"wu_bits_per_sample",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> wu_bits_per_sample;
+	      }
+	      }
+	      }
+
+	void splitter_config::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> version;
+	    }
+	  {  
+	        strncpy(data_type,s[2]->c_str(),64);
+	        data_type[63]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> ifft_len;
+	    }
+	  {  
+	        strncpy(filter,s[5]->c_str(),64);
+	        filter[63]=0;
+	    }
+	  {  
+	        strncpy(window,s[6]->c_str(),64);
+	        window[63]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> samples_per_wu;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> highpass;
+	    }
+	  {  
+	        strncpy(blanker_filter,s[9]->c_str(),64);
+	        blanker_filter[63]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> pfb_ntaps;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> pfb_width_factor;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> wu_bits_per_sample;
+	    }
+	      }
+
+	void splitter_config::parse(const std::string &s) {
+	      SQL_ROW row(&s,13);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<analysis_config>::table_name="analysis_config";
+template <> const char * db_table<analysis_config>::_search_tag=table_name;
+template <> const int db_table<analysis_config>::_nfields=39;
+template <> const char * const db_table<analysis_config>::column_names[39]={"id","spike_thresh","spikes_per_spectrum","autocorr_thresh","autocorr_per_spectrum","autocorr_fftlen","gauss_null_chi_sq_thresh","gauss_chi_sq_thresh","gauss_power_thresh","gauss_peak_power_thresh","gauss_pot_length","pulse_thresh","pulse_display_thresh","pulse_max","pulse_min","pulse_fft_max","pulse_pot_length","triplet_thresh","triplet_max","triplet_min","triplet_pot_length","pot_overlap_factor","pot_t_offset", [...]
+
+analysis_config::analysis_config() : 
+	db_table<analysis_config>(*this,-1),
+	id(0),
+	spike_thresh(0),
+	spikes_per_spectrum(0),
+	autocorr_thresh(0),
+	autocorr_per_spectrum(0),
+	autocorr_fftlen(0),
+	gauss_null_chi_sq_thresh(0),
+	gauss_chi_sq_thresh(0),
+	gauss_power_thresh(0),
+	gauss_peak_power_thresh(0),
+	gauss_pot_length(0),
+	pulse_thresh(0),
+	pulse_display_thresh(0),
+	pulse_max(0),
+	pulse_min(0),
+	pulse_fft_max(0),
+	pulse_pot_length(0),
+	triplet_thresh(0),
+	triplet_max(0),
+	triplet_min(0),
+	triplet_pot_length(0),
+	pot_overlap_factor(0),
+	pot_t_offset(0),
+	pot_min_slew(0),
+	pot_max_slew(0),
+	chirp_resolution(0),
+	analysis_fft_lengths(0),
+	bsmooth_boxcar_length(0),
+	bsmooth_chunk_size(0),
+	chirps((chirp_parameter_t *)0,0,_x_xml_values),
+	pulse_beams(0),
+	max_signals(0),
+	max_spikes(0),
+	max_autocorr(0),
+	max_gaussians(0),
+	max_pulses(0),
+	max_triplets(0),
+	keyuniq(0),
+	credit_rate(0)
+{
+	db_open();
+}
+
+
+analysis_config::analysis_config(const analysis_config &a) : 
+	db_table<analysis_config>(*this,-1),
+	id(a.id),
+	spike_thresh(a.spike_thresh),
+	spikes_per_spectrum(a.spikes_per_spectrum),
+	autocorr_thresh(a.autocorr_thresh),
+	autocorr_per_spectrum(a.autocorr_per_spectrum),
+	autocorr_fftlen(a.autocorr_fftlen),
+	gauss_null_chi_sq_thresh(a.gauss_null_chi_sq_thresh),
+	gauss_chi_sq_thresh(a.gauss_chi_sq_thresh),
+	gauss_power_thresh(a.gauss_power_thresh),
+	gauss_peak_power_thresh(a.gauss_peak_power_thresh),
+	gauss_pot_length(a.gauss_pot_length),
+	pulse_thresh(a.pulse_thresh),
+	pulse_display_thresh(a.pulse_display_thresh),
+	pulse_max(a.pulse_max),
+	pulse_min(a.pulse_min),
+	pulse_fft_max(a.pulse_fft_max),
+	pulse_pot_length(a.pulse_pot_length),
+	triplet_thresh(a.triplet_thresh),
+	triplet_max(a.triplet_max),
+	triplet_min(a.triplet_min),
+	triplet_pot_length(a.triplet_pot_length),
+	pot_overlap_factor(a.pot_overlap_factor),
+	pot_t_offset(a.pot_t_offset),
+	pot_min_slew(a.pot_min_slew),
+	pot_max_slew(a.pot_max_slew),
+	chirp_resolution(a.chirp_resolution),
+	analysis_fft_lengths(a.analysis_fft_lengths),
+	bsmooth_boxcar_length(a.bsmooth_boxcar_length),
+	bsmooth_chunk_size(a.bsmooth_chunk_size),
+	chirps(a.chirps),
+	pulse_beams(a.pulse_beams),
+	max_signals(a.max_signals),
+	max_spikes(a.max_spikes),
+	max_autocorr(a.max_autocorr),
+	max_gaussians(a.max_gaussians),
+	max_pulses(a.max_pulses),
+	max_triplets(a.max_triplets),
+	keyuniq(a.keyuniq),
+	credit_rate(a.credit_rate)
+{
+	db_open();
 }
 
 
-meta_candidate &meta_candidate::operator =(const meta_candidate &a) {
-    if (&a != this) {
-        id=a.id;
-        version=a.version;
-        time_last_updated=a.time_last_updated;
-        num_spikes=a.num_spikes;
-        num_spike_b_multiplets=a.num_spike_b_multiplets;
-        best_spike_b_mp_score=a.best_spike_b_mp_score;
-        num_spike_nb_multiplets=a.num_spike_nb_multiplets;
-        best_spike_nb_mp_score=a.best_spike_nb_mp_score;
-        spike_high_id=a.spike_high_id;
-        num_gaussians=a.num_gaussians;
-        num_gaussian_b_multiplets=a.num_gaussian_b_multiplets;
-        best_gaussian_b_mp_score=a.best_gaussian_b_mp_score;
-        num_gaussian_nb_multiplets=a.num_gaussian_nb_multiplets;
-        best_gaussian_nb_mp_score=a.best_gaussian_nb_mp_score;
-        gaussian_high_id=a.gaussian_high_id;
-        num_pulses=a.num_pulses;
-        num_pulse_b_multiplets=a.num_pulse_b_multiplets;
-        best_pulse_b_mp_score=a.best_pulse_b_mp_score;
-        num_pulse_nb_multiplets=a.num_pulse_nb_multiplets;
-        best_pulse_nb_mp_score=a.best_pulse_nb_mp_score;
-        pulse_high_id=a.pulse_high_id;
-        num_triplets=a.num_triplets;
-        num_triplet_b_multiplets=a.num_triplet_b_multiplets;
-        best_triplet_b_mp_score=a.best_triplet_b_mp_score;
-        num_triplet_nb_multiplets=a.num_triplet_nb_multiplets;
-        best_triplet_nb_mp_score=a.best_triplet_nb_mp_score;
-        triplet_high_id=a.triplet_high_id;
-        num_stars=a.num_stars;
-        best_star_score=a.best_star_score;
-        meta_score=a.meta_score;
-        rfi_clean=a.rfi_clean;
-        state=a.state;
-    }
-    return (*this);
-}
-
-
-std::string meta_candidate::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<32; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string meta_candidate::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string meta_candidate::select_format() const {
-    std::string rv("");
-    for (int i=0; i<31; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string meta_candidate::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << version;
-    rv << ',';
-    rv << time_last_updated;
-    rv << ',';
-    rv << num_spikes;
-    rv << ',';
-    rv << num_spike_b_multiplets;
-    rv << ',';
-    rv << best_spike_b_mp_score;
-    rv << ',';
-    rv << num_spike_nb_multiplets;
-    rv << ',';
-    rv << best_spike_nb_mp_score;
-    rv << ',';
-    rv << spike_high_id;
-    rv << ',';
-    rv << num_gaussians;
-    rv << ',';
-    rv << num_gaussian_b_multiplets;
-    rv << ',';
-    rv << best_gaussian_b_mp_score;
-    rv << ',';
-    rv << num_gaussian_nb_multiplets;
-    rv << ',';
-    rv << best_gaussian_nb_mp_score;
-    rv << ',';
-    rv << gaussian_high_id;
-    rv << ',';
-    rv << num_pulses;
-    rv << ',';
-    rv << num_pulse_b_multiplets;
-    rv << ',';
-    rv << best_pulse_b_mp_score;
-    rv << ',';
-    rv << num_pulse_nb_multiplets;
-    rv << ',';
-    rv << best_pulse_nb_mp_score;
-    rv << ',';
-    rv << pulse_high_id;
-    rv << ',';
-    rv << num_triplets;
-    rv << ',';
-    rv << num_triplet_b_multiplets;
-    rv << ',';
-    rv << best_triplet_b_mp_score;
-    rv << ',';
-    rv << num_triplet_nb_multiplets;
-    rv << ',';
-    rv << best_triplet_nb_mp_score;
-    rv << ',';
-    rv << triplet_high_id;
-    rv << ',';
-    rv << num_stars;
-    rv << ',';
-    rv << best_star_score;
-    rv << ',';
-    rv << meta_score;
-    rv << ',';
-    rv << rfi_clean;
-    rv << ',';
-    rv << state;
-    return rv.str();
-}
-
-
-std::string meta_candidate::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<version>" << version << "</version>\n";
-    rv << xml_indent() << "<time_last_updated>" << time_last_updated << "</time_last_updated>\n";
-    rv << xml_indent() << "<num_spikes>" << num_spikes << "</num_spikes>\n";
-    rv << xml_indent() << "<num_spike_b_multiplets>" << num_spike_b_multiplets << "</num_spike_b_multiplets>\n";
-    rv << xml_indent() << "<best_spike_b_mp_score>" << best_spike_b_mp_score << "</best_spike_b_mp_score>\n";
-    rv << xml_indent() << "<num_spike_nb_multiplets>" << num_spike_nb_multiplets << "</num_spike_nb_multiplets>\n";
-    rv << xml_indent() << "<best_spike_nb_mp_score>" << best_spike_nb_mp_score << "</best_spike_nb_mp_score>\n";
-    rv << xml_indent() << "<spike_high_id>" << spike_high_id << "</spike_high_id>\n";
-    rv << xml_indent() << "<num_gaussians>" << num_gaussians << "</num_gaussians>\n";
-    rv << xml_indent() << "<num_gaussian_b_multiplets>" << num_gaussian_b_multiplets << "</num_gaussian_b_multiplets>\n";
-    rv << xml_indent() << "<best_gaussian_b_mp_score>" << best_gaussian_b_mp_score << "</best_gaussian_b_mp_score>\n";
-    rv << xml_indent() << "<num_gaussian_nb_multiplets>" << num_gaussian_nb_multiplets << "</num_gaussian_nb_multiplets>\n";
-    rv << xml_indent() << "<best_gaussian_nb_mp_score>" << best_gaussian_nb_mp_score << "</best_gaussian_nb_mp_score>\n";
-    rv << xml_indent() << "<gaussian_high_id>" << gaussian_high_id << "</gaussian_high_id>\n";
-    rv << xml_indent() << "<num_pulses>" << num_pulses << "</num_pulses>\n";
-    rv << xml_indent() << "<num_pulse_b_multiplets>" << num_pulse_b_multiplets << "</num_pulse_b_multiplets>\n";
-    rv << xml_indent() << "<best_pulse_b_mp_score>" << best_pulse_b_mp_score << "</best_pulse_b_mp_score>\n";
-    rv << xml_indent() << "<num_pulse_nb_multiplets>" << num_pulse_nb_multiplets << "</num_pulse_nb_multiplets>\n";
-    rv << xml_indent() << "<best_pulse_nb_mp_score>" << best_pulse_nb_mp_score << "</best_pulse_nb_mp_score>\n";
-    rv << xml_indent() << "<pulse_high_id>" << pulse_high_id << "</pulse_high_id>\n";
-    rv << xml_indent() << "<num_triplets>" << num_triplets << "</num_triplets>\n";
-    rv << xml_indent() << "<num_triplet_b_multiplets>" << num_triplet_b_multiplets << "</num_triplet_b_multiplets>\n";
-    rv << xml_indent() << "<best_triplet_b_mp_score>" << best_triplet_b_mp_score << "</best_triplet_b_mp_score>\n";
-    rv << xml_indent() << "<num_triplet_nb_multiplets>" << num_triplet_nb_multiplets << "</num_triplet_nb_multiplets>\n";
-    rv << xml_indent() << "<best_triplet_nb_mp_score>" << best_triplet_nb_mp_score << "</best_triplet_nb_mp_score>\n";
-    rv << xml_indent() << "<triplet_high_id>" << triplet_high_id << "</triplet_high_id>\n";
-    rv << xml_indent() << "<num_stars>" << num_stars << "</num_stars>\n";
-    rv << xml_indent() << "<best_star_score>" << best_star_score << "</best_star_score>\n";
-    rv << xml_indent() << "<meta_score>" << meta_score << "</meta_score>\n";
-    rv << xml_indent() << "<rfi_clean>" << rfi_clean << "</rfi_clean>\n";
-    rv << xml_indent() << "<state>" << state << "</state>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void meta_candidate::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"version",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> version;
-        }
-        if (extract_xml_record(field,"time_last_updated",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time_last_updated;
-        }
-        if (extract_xml_record(field,"num_spikes",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_spikes;
-        }
-        if (extract_xml_record(field,"num_spike_b_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_spike_b_multiplets;
-        }
-        if (extract_xml_record(field,"best_spike_b_mp_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> best_spike_b_mp_score;
-        }
-        if (extract_xml_record(field,"num_spike_nb_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_spike_nb_multiplets;
-        }
-        if (extract_xml_record(field,"best_spike_nb_mp_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> best_spike_nb_mp_score;
-        }
-        if (extract_xml_record(field,"spike_high_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spike_high_id;
-        }
-        if (extract_xml_record(field,"num_gaussians",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_gaussians;
-        }
-        if (extract_xml_record(field,"num_gaussian_b_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_gaussian_b_multiplets;
-        }
-        if (extract_xml_record(field,"best_gaussian_b_mp_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> best_gaussian_b_mp_score;
-        }
-        if (extract_xml_record(field,"num_gaussian_nb_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_gaussian_nb_multiplets;
-        }
-        if (extract_xml_record(field,"best_gaussian_nb_mp_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> best_gaussian_nb_mp_score;
-        }
-        if (extract_xml_record(field,"gaussian_high_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gaussian_high_id;
-        }
-        if (extract_xml_record(field,"num_pulses",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_pulses;
-        }
-        if (extract_xml_record(field,"num_pulse_b_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_pulse_b_multiplets;
-        }
-        if (extract_xml_record(field,"best_pulse_b_mp_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> best_pulse_b_mp_score;
-        }
-        if (extract_xml_record(field,"num_pulse_nb_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_pulse_nb_multiplets;
-        }
-        if (extract_xml_record(field,"best_pulse_nb_mp_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> best_pulse_nb_mp_score;
-        }
-        if (extract_xml_record(field,"pulse_high_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_high_id;
-        }
-        if (extract_xml_record(field,"num_triplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_triplets;
-        }
-        if (extract_xml_record(field,"num_triplet_b_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_triplet_b_multiplets;
-        }
-        if (extract_xml_record(field,"best_triplet_b_mp_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> best_triplet_b_mp_score;
-        }
-        if (extract_xml_record(field,"num_triplet_nb_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_triplet_nb_multiplets;
-        }
-        if (extract_xml_record(field,"best_triplet_nb_mp_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> best_triplet_nb_mp_score;
-        }
-        if (extract_xml_record(field,"triplet_high_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_high_id;
-        }
-        if (extract_xml_record(field,"num_stars",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_stars;
-        }
-        if (extract_xml_record(field,"best_star_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> best_star_score;
-        }
-        if (extract_xml_record(field,"meta_score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> meta_score;
-        }
-        if (extract_xml_record(field,"rfi_clean",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_clean;
-        }
-        if (extract_xml_record(field,"state",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> state;
-        }
-    }
-}
-
-void meta_candidate::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> version;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> time_last_updated;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> num_spikes;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> num_spike_b_multiplets;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> best_spike_b_mp_score;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> num_spike_nb_multiplets;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> best_spike_nb_mp_score;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> spike_high_id;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> num_gaussians;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> num_gaussian_b_multiplets;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> best_gaussian_b_mp_score;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> num_gaussian_nb_multiplets;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> best_gaussian_nb_mp_score;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> gaussian_high_id;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> num_pulses;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> num_pulse_b_multiplets;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> best_pulse_b_mp_score;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> num_pulse_nb_multiplets;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> best_pulse_nb_mp_score;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> pulse_high_id;
-    }
-    {
-        std::istringstream row(*(s[21]));
-        row >> num_triplets;
-    }
-    {
-        std::istringstream row(*(s[22]));
-        row >> num_triplet_b_multiplets;
-    }
-    {
-        std::istringstream row(*(s[23]));
-        row >> best_triplet_b_mp_score;
-    }
-    {
-        std::istringstream row(*(s[24]));
-        row >> num_triplet_nb_multiplets;
-    }
-    {
-        std::istringstream row(*(s[25]));
-        row >> best_triplet_nb_mp_score;
-    }
-    {
-        std::istringstream row(*(s[26]));
-        row >> triplet_high_id;
-    }
-    {
-        std::istringstream row(*(s[27]));
-        row >> num_stars;
-    }
-    {
-        std::istringstream row(*(s[28]));
-        row >> best_star_score;
-    }
-    {
-        std::istringstream row(*(s[29]));
-        row >> meta_score;
-    }
-    {
-        std::istringstream row(*(s[30]));
-        row >> rfi_clean;
-    }
-    {
-        std::istringstream row(*(s[31]));
-        row >> state;
-    }
-}
-
-void meta_candidate::parse(const std::string &s) {
-    SQL_ROW row(&s,32);
-    parse(row);
+analysis_config::analysis_config(const SQL_ROW &a) : 
+	db_table<analysis_config>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
-template <> const char * const db_table<multiplet>::table_name="multiplet";
-template <> const char * db_table<multiplet>::_search_tag=table_name;
-template <> const int db_table<multiplet>::_nfields=25;
-template <> const char * const db_table<multiplet>::column_names[25]= {"id","version","signal_type","mp_type","qpix","freq_win","mean_ra","mean_decl","ra_stddev","decl_stddev","mean_angular_distance","angular_distance_stddev","mean_frequency","frequency_stddev","mean_chirp","chirp_stddev","mean_period","period_stddev","mean_snr","snr_stddev","mean_threshold","threshold_stddev","score","num_detections","signal_ids"};
-
-multiplet::multiplet() :
-    db_table<multiplet>(*this,-1),
-    id(0),
-    version(0),
-    signal_type(0),
-    mp_type(0),
-    qpix(0),
-    freq_win(0),
-    mean_ra(0),
-    mean_decl(0),
-    ra_stddev(0),
-    decl_stddev(0),
-    mean_angular_distance(0),
-    angular_distance_stddev(0),
-    mean_frequency(0),
-    frequency_stddev(0),
-    mean_chirp(0),
-    chirp_stddev(0),
-    mean_period(0),
-    period_stddev(0),
-    mean_snr(0),
-    snr_stddev(0),
-    mean_threshold(0),
-    threshold_stddev(0),
-    score(0),
-    num_detections(0)
-#ifndef NEBULA
-    ,
-    signal_ids((sqlint8_t *)0,0,_x_csv)
-#endif
+
+analysis_config::analysis_config(const std::string &s,const char *tag) : 
+	db_table<analysis_config>(*this,-1)
 {
-    db_open();
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-multiplet::multiplet(const multiplet &a) :
-    db_table<multiplet>(*this,-1),
-    id(a.id),
-    version(a.version),
-    signal_type(a.signal_type),
-    mp_type(a.mp_type),
-    qpix(a.qpix),
-    freq_win(a.freq_win),
-    mean_ra(a.mean_ra),
-    mean_decl(a.mean_decl),
-    ra_stddev(a.ra_stddev),
-    decl_stddev(a.decl_stddev),
-    mean_angular_distance(a.mean_angular_distance),
-    angular_distance_stddev(a.angular_distance_stddev),
-    mean_frequency(a.mean_frequency),
-    frequency_stddev(a.frequency_stddev),
-    mean_chirp(a.mean_chirp),
-    chirp_stddev(a.chirp_stddev),
-    mean_period(a.mean_period),
-    period_stddev(a.period_stddev),
-    mean_snr(a.mean_snr),
-    snr_stddev(a.snr_stddev),
-    mean_threshold(a.mean_threshold),
-    threshold_stddev(a.threshold_stddev),
-    score(a.score),
-    num_detections(a.num_detections),
-    signal_ids(a.signal_ids) {
-    db_open();
+analysis_config &analysis_config::operator =(const analysis_config &a) {
+	if (&a != this) {
+		id=a.id;
+		spike_thresh=a.spike_thresh;
+		spikes_per_spectrum=a.spikes_per_spectrum;
+		autocorr_thresh=a.autocorr_thresh;
+		autocorr_per_spectrum=a.autocorr_per_spectrum;
+		autocorr_fftlen=a.autocorr_fftlen;
+		gauss_null_chi_sq_thresh=a.gauss_null_chi_sq_thresh;
+		gauss_chi_sq_thresh=a.gauss_chi_sq_thresh;
+		gauss_power_thresh=a.gauss_power_thresh;
+		gauss_peak_power_thresh=a.gauss_peak_power_thresh;
+		gauss_pot_length=a.gauss_pot_length;
+		pulse_thresh=a.pulse_thresh;
+		pulse_display_thresh=a.pulse_display_thresh;
+		pulse_max=a.pulse_max;
+		pulse_min=a.pulse_min;
+		pulse_fft_max=a.pulse_fft_max;
+		pulse_pot_length=a.pulse_pot_length;
+		triplet_thresh=a.triplet_thresh;
+		triplet_max=a.triplet_max;
+		triplet_min=a.triplet_min;
+		triplet_pot_length=a.triplet_pot_length;
+		pot_overlap_factor=a.pot_overlap_factor;
+		pot_t_offset=a.pot_t_offset;
+		pot_min_slew=a.pot_min_slew;
+		pot_max_slew=a.pot_max_slew;
+		chirp_resolution=a.chirp_resolution;
+		analysis_fft_lengths=a.analysis_fft_lengths;
+		bsmooth_boxcar_length=a.bsmooth_boxcar_length;
+		bsmooth_chunk_size=a.bsmooth_chunk_size;
+		{
+		  chirps.clear();
+		  std::vector<chirp_parameter_t>::const_iterator i(a.chirps.begin());
+		  for (;i!=a.chirps.end();i++) {
+		    chirps.push_back(*i); 
+		  }
+		}
+		pulse_beams=a.pulse_beams;
+		max_signals=a.max_signals;
+		max_spikes=a.max_spikes;
+		max_autocorr=a.max_autocorr;
+		max_gaussians=a.max_gaussians;
+		max_pulses=a.max_pulses;
+		max_triplets=a.max_triplets;
+		keyuniq=a.keyuniq;
+		credit_rate=a.credit_rate;
+	}
+	return (*this);
+}
+
+
+std::string analysis_config::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<39;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string analysis_config::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string analysis_config::select_format() const
+{
+std::string rv("");
+for (int i=0; i<38;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string analysis_config::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << spike_thresh;
+	rv << ',';
+	rv << spikes_per_spectrum;
+	rv << ',';
+	rv << autocorr_thresh;
+	rv << ',';
+	rv << autocorr_per_spectrum;
+	rv << ',';
+	rv << autocorr_fftlen;
+	rv << ',';
+	rv << gauss_null_chi_sq_thresh;
+	rv << ',';
+	rv << gauss_chi_sq_thresh;
+	rv << ',';
+	rv << gauss_power_thresh;
+	rv << ',';
+	rv << gauss_peak_power_thresh;
+	rv << ',';
+	rv << gauss_pot_length;
+	rv << ',';
+	rv << pulse_thresh;
+	rv << ',';
+	rv << pulse_display_thresh;
+	rv << ',';
+	rv << pulse_max;
+	rv << ',';
+	rv << pulse_min;
+	rv << ',';
+	rv << pulse_fft_max;
+	rv << ',';
+	rv << pulse_pot_length;
+	rv << ',';
+	rv << triplet_thresh;
+	rv << ',';
+	rv << triplet_max;
+	rv << ',';
+	rv << triplet_min;
+	rv << ',';
+	rv << triplet_pot_length;
+	rv << ',';
+	rv << pot_overlap_factor;
+	rv << ',';
+	rv << pot_t_offset;
+	rv << ',';
+	rv << pot_min_slew;
+	rv << ',';
+	rv << pot_max_slew;
+	rv << ',';
+	rv << chirp_resolution;
+	rv << ',';
+	rv << analysis_fft_lengths;
+	rv << ',';
+	rv << bsmooth_boxcar_length;
+	rv << ',';
+	rv << bsmooth_chunk_size;
+	rv << ',';
+	rv << "LIST {";
+	{
+	std::vector<chirp_parameter_t>::const_iterator p=chirps.begin();
+	for (;p<chirps.end();p++) {
+	  rv << p->print();
+	  if (p != chirps.end()-1) {
+	    rv << ',';
+	  } else {
+	    rv << "}";
+	  }
+	}
+	}
+	rv << ',';
+	rv << pulse_beams;
+	rv << ',';
+	rv << max_signals;
+	rv << ',';
+	rv << max_spikes;
+	rv << ',';
+	rv << max_autocorr;
+	rv << ',';
+	rv << max_gaussians;
+	rv << ',';
+	rv << max_pulses;
+	rv << ',';
+	rv << max_triplets;
+	rv << ',';
+	rv << keyuniq;
+	rv << ',';
+	rv << credit_rate;
+	return rv.str();
+}
+
+
+std::string analysis_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<spike_thresh>" << spike_thresh << "</spike_thresh>\n";
+	rv << xml_indent() << "<spikes_per_spectrum>" << spikes_per_spectrum << "</spikes_per_spectrum>\n";
+	rv << xml_indent() << "<autocorr_thresh>" << autocorr_thresh << "</autocorr_thresh>\n";
+	rv << xml_indent() << "<autocorr_per_spectrum>" << autocorr_per_spectrum << "</autocorr_per_spectrum>\n";
+	rv << xml_indent() << "<autocorr_fftlen>" << autocorr_fftlen << "</autocorr_fftlen>\n";
+	rv << xml_indent() << "<gauss_null_chi_sq_thresh>" << gauss_null_chi_sq_thresh << "</gauss_null_chi_sq_thresh>\n";
+	rv << xml_indent() << "<gauss_chi_sq_thresh>" << gauss_chi_sq_thresh << "</gauss_chi_sq_thresh>\n";
+	rv << xml_indent() << "<gauss_power_thresh>" << gauss_power_thresh << "</gauss_power_thresh>\n";
+	rv << xml_indent() << "<gauss_peak_power_thresh>" << gauss_peak_power_thresh << "</gauss_peak_power_thresh>\n";
+	rv << xml_indent() << "<gauss_pot_length>" << gauss_pot_length << "</gauss_pot_length>\n";
+	rv << xml_indent() << "<pulse_thresh>" << pulse_thresh << "</pulse_thresh>\n";
+	rv << xml_indent() << "<pulse_display_thresh>" << pulse_display_thresh << "</pulse_display_thresh>\n";
+	rv << xml_indent() << "<pulse_max>" << pulse_max << "</pulse_max>\n";
+	rv << xml_indent() << "<pulse_min>" << pulse_min << "</pulse_min>\n";
+	rv << xml_indent() << "<pulse_fft_max>" << pulse_fft_max << "</pulse_fft_max>\n";
+	rv << xml_indent() << "<pulse_pot_length>" << pulse_pot_length << "</pulse_pot_length>\n";
+	rv << xml_indent() << "<triplet_thresh>" << triplet_thresh << "</triplet_thresh>\n";
+	rv << xml_indent() << "<triplet_max>" << triplet_max << "</triplet_max>\n";
+	rv << xml_indent() << "<triplet_min>" << triplet_min << "</triplet_min>\n";
+	rv << xml_indent() << "<triplet_pot_length>" << triplet_pot_length << "</triplet_pot_length>\n";
+	rv << xml_indent() << "<pot_overlap_factor>" << pot_overlap_factor << "</pot_overlap_factor>\n";
+	rv << xml_indent() << "<pot_t_offset>" << pot_t_offset << "</pot_t_offset>\n";
+	rv << xml_indent() << "<pot_min_slew>" << pot_min_slew << "</pot_min_slew>\n";
+	rv << xml_indent() << "<pot_max_slew>" << pot_max_slew << "</pot_max_slew>\n";
+	rv << xml_indent() << "<chirp_resolution>" << chirp_resolution << "</chirp_resolution>\n";
+	rv << xml_indent() << "<analysis_fft_lengths>" << analysis_fft_lengths << "</analysis_fft_lengths>\n";
+	rv << xml_indent() << "<bsmooth_boxcar_length>" << bsmooth_boxcar_length << "</bsmooth_boxcar_length>\n";
+	rv << xml_indent() << "<bsmooth_chunk_size>" << bsmooth_chunk_size << "</bsmooth_chunk_size>\n";
+	if (chirps.size()) {
+	  rv << xml_indent() << "<chirps";
+	  {
+	    std::string enc_string=chirps.print_xml();
+	    rv << ">\n" ;
+	    rv << enc_string;
+	  }
+}
+	rv << xml_indent(-2);
+	rv << "</chirps>\n"; 
+	rv << xml_indent() << "<pulse_beams>" << pulse_beams << "</pulse_beams>\n";
+	rv << xml_indent() << "<max_signals>" << max_signals << "</max_signals>\n";
+	rv << xml_indent() << "<max_spikes>" << max_spikes << "</max_spikes>\n";
+	rv << xml_indent() << "<max_autocorr>" << max_autocorr << "</max_autocorr>\n";
+	rv << xml_indent() << "<max_gaussians>" << max_gaussians << "</max_gaussians>\n";
+	rv << xml_indent() << "<max_pulses>" << max_pulses << "</max_pulses>\n";
+	rv << xml_indent() << "<max_triplets>" << max_triplets << "</max_triplets>\n";
+	rv << xml_indent() << "<keyuniq>" << keyuniq << "</keyuniq>\n";
+	rv << xml_indent() << "<credit_rate>" << credit_rate << "</credit_rate>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void analysis_config::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"spike_thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spike_thresh;
+	      }
+	    if (extract_xml_record(field,"spikes_per_spectrum",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spikes_per_spectrum;
+	      }
+	    if (extract_xml_record(field,"autocorr_thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> autocorr_thresh;
+	      }
+	    if (extract_xml_record(field,"autocorr_per_spectrum",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> autocorr_per_spectrum;
+	      }
+	    if (extract_xml_record(field,"autocorr_fftlen",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> autocorr_fftlen;
+	      }
+	    if (extract_xml_record(field,"gauss_null_chi_sq_thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gauss_null_chi_sq_thresh;
+	      }
+	    if (extract_xml_record(field,"gauss_chi_sq_thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gauss_chi_sq_thresh;
+	      }
+	    if (extract_xml_record(field,"gauss_power_thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gauss_power_thresh;
+	      }
+	    if (extract_xml_record(field,"gauss_peak_power_thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gauss_peak_power_thresh;
+	      }
+	    if (extract_xml_record(field,"gauss_pot_length",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gauss_pot_length;
+	      }
+	    if (extract_xml_record(field,"pulse_thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_thresh;
+	      }
+	    if (extract_xml_record(field,"pulse_display_thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_display_thresh;
+	      }
+	    if (extract_xml_record(field,"pulse_max",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_max;
+	      }
+	    if (extract_xml_record(field,"pulse_min",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_min;
+	      }
+	    if (extract_xml_record(field,"pulse_fft_max",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_fft_max;
+	      }
+	    if (extract_xml_record(field,"pulse_pot_length",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_pot_length;
+	      }
+	    if (extract_xml_record(field,"triplet_thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_thresh;
+	      }
+	    if (extract_xml_record(field,"triplet_max",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_max;
+	      }
+	    if (extract_xml_record(field,"triplet_min",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_min;
+	      }
+	    if (extract_xml_record(field,"triplet_pot_length",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_pot_length;
+	      }
+	    if (extract_xml_record(field,"pot_overlap_factor",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pot_overlap_factor;
+	      }
+	    if (extract_xml_record(field,"pot_t_offset",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pot_t_offset;
+	      }
+	    if (extract_xml_record(field,"pot_min_slew",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pot_min_slew;
+	      }
+	    if (extract_xml_record(field,"pot_max_slew",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pot_max_slew;
+	      }
+	    if (extract_xml_record(field,"chirp_resolution",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_resolution;
+	      }
+	    if (extract_xml_record(field,"analysis_fft_lengths",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> analysis_fft_lengths;
+	      }
+	    if (extract_xml_record(field,"bsmooth_boxcar_length",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> bsmooth_boxcar_length;
+	      }
+	    if (extract_xml_record(field,"bsmooth_chunk_size",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> bsmooth_chunk_size;
+	      }
+	    chirps.clear();
+	    if (extract_xml_record(field,"chirps",sub)) {
+	      pos=0;
+	      while ((pos=sub.find("<chirp_parameter_t",pos)) != std::string::npos) { 
+	        chirps.push_back(chirp_parameter_t(std::string(sub.c_str()+pos))); 
+	         pos=sub.find("</chirp_parameter_t",pos);
+	      pos=sub.find(">",pos);
+	      }
+	    }
+	    if (extract_xml_record(field,"pulse_beams",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_beams;
+	      }
+	    if (extract_xml_record(field,"max_signals",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_signals;
+	      }
+	    if (extract_xml_record(field,"max_spikes",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_spikes;
+	      }
+	    if (extract_xml_record(field,"max_autocorr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_autocorr;
+	      }
+	    if (extract_xml_record(field,"max_gaussians",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_gaussians;
+	      }
+	    if (extract_xml_record(field,"max_pulses",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_pulses;
+	      }
+	    if (extract_xml_record(field,"max_triplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_triplets;
+	      }
+	    if (extract_xml_record(field,"keyuniq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> keyuniq;
+	      }
+	    if (extract_xml_record(field,"credit_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> credit_rate;
+	      }
+	      }
+	      }
+
+	void analysis_config::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> spike_thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> spikes_per_spectrum;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> autocorr_thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> autocorr_per_spectrum;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> autocorr_fftlen;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> gauss_null_chi_sq_thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> gauss_chi_sq_thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> gauss_power_thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> gauss_peak_power_thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> gauss_pot_length;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> pulse_thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> pulse_display_thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> pulse_max;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> pulse_min;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> pulse_fft_max;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> pulse_pot_length;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> triplet_thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> triplet_max;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> triplet_min;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> triplet_pot_length;
+	    }
+	  {  
+	        std::istringstream row(*(s[21]));
+	        row >> pot_overlap_factor;
+	    }
+	  {  
+	        std::istringstream row(*(s[22]));
+	        row >> pot_t_offset;
+	    }
+	  {  
+	        std::istringstream row(*(s[23]));
+	        row >> pot_min_slew;
+	    }
+	  {  
+	        std::istringstream row(*(s[24]));
+	        row >> pot_max_slew;
+	    }
+	  {  
+	        std::istringstream row(*(s[25]));
+	        row >> chirp_resolution;
+	    }
+	  {  
+	        std::istringstream row(*(s[26]));
+	        row >> analysis_fft_lengths;
+	    }
+	  {  
+	        std::istringstream row(*(s[27]));
+	        row >> bsmooth_boxcar_length;
+	    }
+	  {  
+	        std::istringstream row(*(s[28]));
+	        row >> bsmooth_chunk_size;
+	    }
+	  {  
+	  std::string::size_type p,q;
+	  int i;
+	    chirps.clear();
+	      SQL_ROW tmp(s[29]); 
+	      for (i=0;i<tmp.argc();i++) {
+	 chirps.push_back(chirp_parameter_t(SQL_ROW(tmp[i])));
+	      }
+	    }
+	  {  
+	        std::istringstream row(*(s[30]));
+	        row >> pulse_beams;
+	    }
+	  {  
+	        std::istringstream row(*(s[31]));
+	        row >> max_signals;
+	    }
+	  {  
+	        std::istringstream row(*(s[32]));
+	        row >> max_spikes;
+	    }
+	  {  
+	        std::istringstream row(*(s[33]));
+	        row >> max_autocorr;
+	    }
+	  {  
+	        std::istringstream row(*(s[34]));
+	        row >> max_gaussians;
+	    }
+	  {  
+	        std::istringstream row(*(s[35]));
+	        row >> max_pulses;
+	    }
+	  {  
+	        std::istringstream row(*(s[36]));
+	        row >> max_triplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[37]));
+	        row >> keyuniq;
+	    }
+	  {  
+	        std::istringstream row(*(s[38]));
+	        row >> credit_rate;
+	    }
+	      }
+
+	void analysis_config::parse(const std::string &s) {
+	      SQL_ROW row(&s,39);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<science_config>::table_name="science_config";
+template <> const char * db_table<science_config>::_search_tag=table_name;
+template <> const int db_table<science_config>::_nfields=29;
+template <> const char * const db_table<science_config>::column_names[29]={"id","active","qpix_scheme","qpix_nside","fpix_width","total_bandwidth","freq_uncertainty","fwhm_beamwidth","sky_disc_radius","observable_sky","epoch","bary_chirp_window","bary_freq_window","nonbary_freq_window","spike_obs_duration","spike_obs_interval","gauss_obs_duration","gauss_obs_interval","pulse_obs_duration","pulse_obs_interval","triplet_obs_duration","triplet_obs_interval","min_spike_id","min_autocorr_id", [...]
+
+science_config::science_config() : 
+	db_table<science_config>(*this,-1),
+	id(0),
+	active(0),
+	qpix_nside(0),
+	fpix_width(0),
+	total_bandwidth(0),
+	freq_uncertainty(0),
+	fwhm_beamwidth(0),
+	sky_disc_radius(0),
+	observable_sky(0),
+	epoch(0),
+	bary_chirp_window(0),
+	bary_freq_window(0),
+	nonbary_freq_window(0),
+	spike_obs_duration(0),
+	spike_obs_interval(0),
+	gauss_obs_duration(0),
+	gauss_obs_interval(0),
+	pulse_obs_duration(0),
+	pulse_obs_interval(0),
+	triplet_obs_duration(0),
+	triplet_obs_interval(0),
+	min_spike_id(0),
+	min_autocorr_id(0),
+	min_gaussian_id(0),
+	min_pulse_id(0),
+	min_triplet_id(0),
+	min_app_version(0)
+{
+	db_open();
+	qpix_scheme[0]=0;
+	info_xml[0]=0;
+}
+
+
+science_config::science_config(const science_config &a) : 
+	db_table<science_config>(*this,-1),
+	id(a.id),
+	active(a.active),
+	qpix_nside(a.qpix_nside),
+	fpix_width(a.fpix_width),
+	total_bandwidth(a.total_bandwidth),
+	freq_uncertainty(a.freq_uncertainty),
+	fwhm_beamwidth(a.fwhm_beamwidth),
+	sky_disc_radius(a.sky_disc_radius),
+	observable_sky(a.observable_sky),
+	epoch(a.epoch),
+	bary_chirp_window(a.bary_chirp_window),
+	bary_freq_window(a.bary_freq_window),
+	nonbary_freq_window(a.nonbary_freq_window),
+	spike_obs_duration(a.spike_obs_duration),
+	spike_obs_interval(a.spike_obs_interval),
+	gauss_obs_duration(a.gauss_obs_duration),
+	gauss_obs_interval(a.gauss_obs_interval),
+	pulse_obs_duration(a.pulse_obs_duration),
+	pulse_obs_interval(a.pulse_obs_interval),
+	triplet_obs_duration(a.triplet_obs_duration),
+	triplet_obs_interval(a.triplet_obs_interval),
+	min_spike_id(a.min_spike_id),
+	min_autocorr_id(a.min_autocorr_id),
+	min_gaussian_id(a.min_gaussian_id),
+	min_pulse_id(a.min_pulse_id),
+	min_triplet_id(a.min_triplet_id),
+	min_app_version(a.min_app_version)
+{
+	db_open();
+	strcpy(qpix_scheme,a.qpix_scheme);
+	strcpy(info_xml,a.info_xml);
 }
 
 
-multiplet::multiplet(const SQL_ROW &a) :
-    db_table<multiplet>(*this,-1) {
-    db_open();
-    parse(a);
+science_config::science_config(const SQL_ROW &a) : 
+	db_table<science_config>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-multiplet::multiplet(const std::string &s,const char *tag) :
-    db_table<multiplet>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+science_config::science_config(const std::string &s,const char *tag) : 
+	db_table<science_config>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-multiplet &multiplet::operator =(const multiplet &a) {
-    if (&a != this) {
-        id=a.id;
-        version=a.version;
-        signal_type=a.signal_type;
-        mp_type=a.mp_type;
-        qpix=a.qpix;
-        freq_win=a.freq_win;
-        mean_ra=a.mean_ra;
-        mean_decl=a.mean_decl;
-        ra_stddev=a.ra_stddev;
-        decl_stddev=a.decl_stddev;
-        mean_angular_distance=a.mean_angular_distance;
-        angular_distance_stddev=a.angular_distance_stddev;
-        mean_frequency=a.mean_frequency;
-        frequency_stddev=a.frequency_stddev;
-        mean_chirp=a.mean_chirp;
-        chirp_stddev=a.chirp_stddev;
-        mean_period=a.mean_period;
-        period_stddev=a.period_stddev;
-        mean_snr=a.mean_snr;
-        snr_stddev=a.snr_stddev;
-        mean_threshold=a.mean_threshold;
-        threshold_stddev=a.threshold_stddev;
-        score=a.score;
-        num_detections=a.num_detections;
-        {
-            signal_ids.clear();
-            std::vector<sqlint8_t>::const_iterator i(a.signal_ids.begin());
-            for (; i!=a.signal_ids.end(); i++) {
-                signal_ids.push_back(*i);
-            }
-        }
-    }
-    return (*this);
-}
-
-
-std::string multiplet::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<25; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string multiplet::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string multiplet::select_format() const {
-    std::string rv("");
-    for (int i=0; i<24; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string multiplet::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << version;
-    rv << ',';
-    rv << signal_type;
-    rv << ',';
-    rv << mp_type;
-    rv << ',';
-    rv << qpix;
-    rv << ',';
-    rv << freq_win;
-    rv << ',';
-    rv << mean_ra;
-    rv << ',';
-    rv << mean_decl;
-    rv << ',';
-    rv << ra_stddev;
-    rv << ',';
-    rv << decl_stddev;
-    rv << ',';
-    rv << mean_angular_distance;
-    rv << ',';
-    rv << angular_distance_stddev;
-    rv << ',';
-    rv << mean_frequency;
-    rv << ',';
-    rv << frequency_stddev;
-    rv << ',';
-    rv << mean_chirp;
-    rv << ',';
-    rv << chirp_stddev;
-    rv << ',';
-    rv << mean_period;
-    rv << ',';
-    rv << period_stddev;
-    rv << ',';
-    rv << mean_snr;
-    rv << ',';
-    rv << snr_stddev;
-    rv << ',';
-    rv << mean_threshold;
-    rv << ',';
-    rv << threshold_stddev;
-    rv << ',';
-    rv << score;
-    rv << ',';
-    rv << num_detections;
-    rv << ',';
-    rv << "LIST {";
-    {
-        std::vector<sqlint8_t>::const_iterator p=signal_ids.begin();
-        for (; p<signal_ids.end(); p++) {
-            rv << *p;
-            if (p != signal_ids.end()-1) {
-                rv << ',';
-            } else {
-                rv << "}";
-            }
-        }
-    }
-    return rv.str();
-}
-
-
-std::string multiplet::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<version>" << version << "</version>\n";
-    rv << xml_indent() << "<signal_type>" << signal_type << "</signal_type>\n";
-    rv << xml_indent() << "<mp_type>" << mp_type << "</mp_type>\n";
-    rv << xml_indent() << "<qpix>" << qpix << "</qpix>\n";
-    rv << xml_indent() << "<freq_win>" << freq_win << "</freq_win>\n";
-    rv << xml_indent() << "<mean_ra>" << mean_ra << "</mean_ra>\n";
-    rv << xml_indent() << "<mean_decl>" << mean_decl << "</mean_decl>\n";
-    rv << xml_indent() << "<ra_stddev>" << ra_stddev << "</ra_stddev>\n";
-    rv << xml_indent() << "<decl_stddev>" << decl_stddev << "</decl_stddev>\n";
-    rv << xml_indent() << "<mean_angular_distance>" << mean_angular_distance << "</mean_angular_distance>\n";
-    rv << xml_indent() << "<angular_distance_stddev>" << angular_distance_stddev << "</angular_distance_stddev>\n";
-    rv << xml_indent() << "<mean_frequency>" << mean_frequency << "</mean_frequency>\n";
-    rv << xml_indent() << "<frequency_stddev>" << frequency_stddev << "</frequency_stddev>\n";
-    rv << xml_indent() << "<mean_chirp>" << mean_chirp << "</mean_chirp>\n";
-    rv << xml_indent() << "<chirp_stddev>" << chirp_stddev << "</chirp_stddev>\n";
-    rv << xml_indent() << "<mean_period>" << mean_period << "</mean_period>\n";
-    rv << xml_indent() << "<period_stddev>" << period_stddev << "</period_stddev>\n";
-    rv << xml_indent() << "<mean_snr>" << mean_snr << "</mean_snr>\n";
-    rv << xml_indent() << "<snr_stddev>" << snr_stddev << "</snr_stddev>\n";
-    rv << xml_indent() << "<mean_threshold>" << mean_threshold << "</mean_threshold>\n";
-    rv << xml_indent() << "<threshold_stddev>" << threshold_stddev << "</threshold_stddev>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    rv << xml_indent() << "<num_detections>" << num_detections << "</num_detections>\n";
-#ifndef NEBULA
-    if (signal_ids.size()) {
-        rv << xml_indent() << "<signal_ids";
-        {
-            std::string enc_string=signal_ids.print_xml();
-            rv << " length=" << enc_string.size() << " encoding=\"" << xml_encoding_names[signal_ids.encoding] << "\">" ;
-            rv << enc_string;
-        }
-    }
-#endif
-    rv << "</signal_ids>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void multiplet::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"version",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> version;
-        }
-        if (extract_xml_record(field,"signal_type",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> signal_type;
-        }
-        if (extract_xml_record(field,"mp_type",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mp_type;
-        }
-        if (extract_xml_record(field,"qpix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> qpix;
-        }
-        if (extract_xml_record(field,"freq_win",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq_win;
-        }
-        if (extract_xml_record(field,"mean_ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_ra;
-        }
-        if (extract_xml_record(field,"mean_decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_decl;
-        }
-        if (extract_xml_record(field,"ra_stddev",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra_stddev;
-        }
-        if (extract_xml_record(field,"decl_stddev",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl_stddev;
-        }
-        if (extract_xml_record(field,"mean_angular_distance",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_angular_distance;
-        }
-        if (extract_xml_record(field,"angular_distance_stddev",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> angular_distance_stddev;
-        }
-        if (extract_xml_record(field,"mean_frequency",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_frequency;
-        }
-        if (extract_xml_record(field,"frequency_stddev",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> frequency_stddev;
-        }
-        if (extract_xml_record(field,"mean_chirp",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_chirp;
-        }
-        if (extract_xml_record(field,"chirp_stddev",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_stddev;
-        }
-        if (extract_xml_record(field,"mean_period",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_period;
-        }
-        if (extract_xml_record(field,"period_stddev",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> period_stddev;
-        }
-        if (extract_xml_record(field,"mean_snr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_snr;
-        }
-        if (extract_xml_record(field,"snr_stddev",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> snr_stddev;
-        }
-        if (extract_xml_record(field,"mean_threshold",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_threshold;
-        }
-        if (extract_xml_record(field,"threshold_stddev",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> threshold_stddev;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-        if (extract_xml_record(field,"num_detections",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> num_detections;
-        }
-        signal_ids.clear();
-        if (extract_xml_record(field,"signal_ids",sub)) {
-            pos=sub.find(">");
-            do {
-                if (pos!=std::string::npos) {
-                    do {
-                        pos++;
-                    } while ((sub[pos]=='\n') || (sub[pos]==','));
-                    std::istringstream in(std::string(sub.c_str()+pos));
-                    sqlint8_t tmp;
-                    in >> tmp;
-                    signal_ids.push_back(tmp);
-                }
-            } while ((pos=sub.find(",",pos)) != std::string::npos);
-        }
-    }
-}
-
-void multiplet::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> version;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> signal_type;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mp_type;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> qpix;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> freq_win;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> mean_ra;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> mean_decl;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> ra_stddev;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> decl_stddev;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> mean_angular_distance;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> angular_distance_stddev;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> mean_frequency;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> frequency_stddev;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> mean_chirp;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> chirp_stddev;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> mean_period;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> period_stddev;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> mean_snr;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> snr_stddev;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> mean_threshold;
-    }
-    {
-        std::istringstream row(*(s[21]));
-        row >> threshold_stddev;
-    }
-    {
-        std::istringstream row(*(s[22]));
-        row >> score;
-    }
-    {
-        std::istringstream row(*(s[23]));
-        row >> num_detections;
-    }
-    {
-        std::string::size_type p,q;
-        int i;
-        signal_ids.clear();
-        SQL_ROW tmp(s[24]);
-        for (i=0; i<tmp.argc(); i++) {
-            std::istringstream in(*(tmp[i]));
-            sqlint8_t tmp0;
-            in >> tmp0;
-            signal_ids.push_back(tmp0);
-        }
-    }
-}
-
-void multiplet::parse(const std::string &s) {
-    SQL_ROW row(&s,25);
-    parse(row);
-}
+science_config &science_config::operator =(const science_config &a) {
+	if (&a != this) {
+		id=a.id;
+		active=a.active;
+		qpix_nside=a.qpix_nside;
+		fpix_width=a.fpix_width;
+		total_bandwidth=a.total_bandwidth;
+		freq_uncertainty=a.freq_uncertainty;
+		fwhm_beamwidth=a.fwhm_beamwidth;
+		sky_disc_radius=a.sky_disc_radius;
+		observable_sky=a.observable_sky;
+		epoch=a.epoch;
+		bary_chirp_window=a.bary_chirp_window;
+		bary_freq_window=a.bary_freq_window;
+		nonbary_freq_window=a.nonbary_freq_window;
+		spike_obs_duration=a.spike_obs_duration;
+		spike_obs_interval=a.spike_obs_interval;
+		gauss_obs_duration=a.gauss_obs_duration;
+		gauss_obs_interval=a.gauss_obs_interval;
+		pulse_obs_duration=a.pulse_obs_duration;
+		pulse_obs_interval=a.pulse_obs_interval;
+		triplet_obs_duration=a.triplet_obs_duration;
+		triplet_obs_interval=a.triplet_obs_interval;
+		min_spike_id=a.min_spike_id;
+		min_autocorr_id=a.min_autocorr_id;
+		min_gaussian_id=a.min_gaussian_id;
+		min_pulse_id=a.min_pulse_id;
+		min_triplet_id=a.min_triplet_id;
+		min_app_version=a.min_app_version;
+	strcpy(qpix_scheme,a.qpix_scheme);
+	strcpy(info_xml,a.info_xml);
+	}
+	return (*this);
+}
+
+
+std::string science_config::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<29;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string science_config::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string science_config::select_format() const
+{
+std::string rv("");
+for (int i=0; i<28;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string science_config::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << active;
+	rv << ',';
+	rv << "'" << qpix_scheme << "'";
+	rv << ',';
+	rv << qpix_nside;
+	rv << ',';
+	rv << fpix_width;
+	rv << ',';
+	rv << total_bandwidth;
+	rv << ',';
+	rv << freq_uncertainty;
+	rv << ',';
+	rv << fwhm_beamwidth;
+	rv << ',';
+	rv << sky_disc_radius;
+	rv << ',';
+	rv << observable_sky;
+	rv << ',';
+	rv << epoch;
+	rv << ',';
+	rv << bary_chirp_window;
+	rv << ',';
+	rv << bary_freq_window;
+	rv << ',';
+	rv << nonbary_freq_window;
+	rv << ',';
+	rv << spike_obs_duration;
+	rv << ',';
+	rv << spike_obs_interval;
+	rv << ',';
+	rv << gauss_obs_duration;
+	rv << ',';
+	rv << gauss_obs_interval;
+	rv << ',';
+	rv << pulse_obs_duration;
+	rv << ',';
+	rv << pulse_obs_interval;
+	rv << ',';
+	rv << triplet_obs_duration;
+	rv << ',';
+	rv << triplet_obs_interval;
+	rv << ',';
+	rv << min_spike_id;
+	rv << ',';
+	rv << min_autocorr_id;
+	rv << ',';
+	rv << min_gaussian_id;
+	rv << ',';
+	rv << min_pulse_id;
+	rv << ',';
+	rv << min_triplet_id;
+	rv << ',';
+	rv << min_app_version;
+	rv << ',';
+	rv << "'" << info_xml << "'";
+	return rv.str();
+}
+
+
+std::string science_config::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<active>" << active << "</active>\n";
+	{
+	  std::string enc_field=xml_encode_string(qpix_scheme,std::min(strlen(qpix_scheme),sizeof(qpix_scheme)));
+	  rv << xml_indent() << "<qpix_scheme>";
+	  rv << enc_field << "</qpix_scheme>\n";
+	}
+	rv << xml_indent() << "<qpix_nside>" << qpix_nside << "</qpix_nside>\n";
+	rv << xml_indent() << "<fpix_width>" << fpix_width << "</fpix_width>\n";
+	rv << xml_indent() << "<total_bandwidth>" << total_bandwidth << "</total_bandwidth>\n";
+	rv << xml_indent() << "<freq_uncertainty>" << freq_uncertainty << "</freq_uncertainty>\n";
+	rv << xml_indent() << "<fwhm_beamwidth>" << fwhm_beamwidth << "</fwhm_beamwidth>\n";
+	rv << xml_indent() << "<sky_disc_radius>" << sky_disc_radius << "</sky_disc_radius>\n";
+	rv << xml_indent() << "<observable_sky>" << observable_sky << "</observable_sky>\n";
+	rv << xml_indent() << "<epoch>" << epoch << "</epoch>\n";
+	rv << xml_indent() << "<bary_chirp_window>" << bary_chirp_window << "</bary_chirp_window>\n";
+	rv << xml_indent() << "<bary_freq_window>" << bary_freq_window << "</bary_freq_window>\n";
+	rv << xml_indent() << "<nonbary_freq_window>" << nonbary_freq_window << "</nonbary_freq_window>\n";
+	rv << xml_indent() << "<spike_obs_duration>" << spike_obs_duration << "</spike_obs_duration>\n";
+	rv << xml_indent() << "<spike_obs_interval>" << spike_obs_interval << "</spike_obs_interval>\n";
+	rv << xml_indent() << "<gauss_obs_duration>" << gauss_obs_duration << "</gauss_obs_duration>\n";
+	rv << xml_indent() << "<gauss_obs_interval>" << gauss_obs_interval << "</gauss_obs_interval>\n";
+	rv << xml_indent() << "<pulse_obs_duration>" << pulse_obs_duration << "</pulse_obs_duration>\n";
+	rv << xml_indent() << "<pulse_obs_interval>" << pulse_obs_interval << "</pulse_obs_interval>\n";
+	rv << xml_indent() << "<triplet_obs_duration>" << triplet_obs_duration << "</triplet_obs_duration>\n";
+	rv << xml_indent() << "<triplet_obs_interval>" << triplet_obs_interval << "</triplet_obs_interval>\n";
+	rv << xml_indent() << "<min_spike_id>" << min_spike_id << "</min_spike_id>\n";
+	rv << xml_indent() << "<min_autocorr_id>" << min_autocorr_id << "</min_autocorr_id>\n";
+	rv << xml_indent() << "<min_gaussian_id>" << min_gaussian_id << "</min_gaussian_id>\n";
+	rv << xml_indent() << "<min_pulse_id>" << min_pulse_id << "</min_pulse_id>\n";
+	rv << xml_indent() << "<min_triplet_id>" << min_triplet_id << "</min_triplet_id>\n";
+	rv << xml_indent() << "<min_app_version>" << min_app_version << "</min_app_version>\n";
+	{
+	  std::string enc_field=xml_encode_string(info_xml,std::min(strlen(info_xml),sizeof(info_xml)));
+	  rv << xml_indent() << "<info_xml>";
+	  rv << enc_field << "</info_xml>\n";
+	}
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void science_config::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"active",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> active;
+	      }
+	    if (extract_xml_record(field,"qpix_scheme",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(qpix_scheme,(const char *)&(in.front()),std::min(in.size(),(size_t)16));
+	        qpix_scheme[std::min(in.size(),(size_t)15)]=0;
+	      }
+	    if (extract_xml_record(field,"qpix_nside",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> qpix_nside;
+	      }
+	    if (extract_xml_record(field,"fpix_width",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fpix_width;
+	      }
+	    if (extract_xml_record(field,"total_bandwidth",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> total_bandwidth;
+	      }
+	    if (extract_xml_record(field,"freq_uncertainty",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq_uncertainty;
+	      }
+	    if (extract_xml_record(field,"fwhm_beamwidth",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fwhm_beamwidth;
+	      }
+	    if (extract_xml_record(field,"sky_disc_radius",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> sky_disc_radius;
+	      }
+	    if (extract_xml_record(field,"observable_sky",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> observable_sky;
+	      }
+	    if (extract_xml_record(field,"epoch",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> epoch;
+	      }
+	    if (extract_xml_record(field,"bary_chirp_window",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> bary_chirp_window;
+	      }
+	    if (extract_xml_record(field,"bary_freq_window",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> bary_freq_window;
+	      }
+	    if (extract_xml_record(field,"nonbary_freq_window",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> nonbary_freq_window;
+	      }
+	    if (extract_xml_record(field,"spike_obs_duration",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spike_obs_duration;
+	      }
+	    if (extract_xml_record(field,"spike_obs_interval",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spike_obs_interval;
+	      }
+	    if (extract_xml_record(field,"gauss_obs_duration",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gauss_obs_duration;
+	      }
+	    if (extract_xml_record(field,"gauss_obs_interval",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gauss_obs_interval;
+	      }
+	    if (extract_xml_record(field,"pulse_obs_duration",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_obs_duration;
+	      }
+	    if (extract_xml_record(field,"pulse_obs_interval",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_obs_interval;
+	      }
+	    if (extract_xml_record(field,"triplet_obs_duration",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_obs_duration;
+	      }
+	    if (extract_xml_record(field,"triplet_obs_interval",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_obs_interval;
+	      }
+	    if (extract_xml_record(field,"min_spike_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_spike_id;
+	      }
+	    if (extract_xml_record(field,"min_autocorr_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_autocorr_id;
+	      }
+	    if (extract_xml_record(field,"min_gaussian_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_gaussian_id;
+	      }
+	    if (extract_xml_record(field,"min_pulse_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_pulse_id;
+	      }
+	    if (extract_xml_record(field,"min_triplet_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_triplet_id;
+	      }
+	    if (extract_xml_record(field,"min_app_version",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_app_version;
+	      }
+	    if (extract_xml_record(field,"info_xml",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(info_xml,(const char *)&(in.front()),std::min(in.size(),(size_t)255));
+	        info_xml[std::min(in.size(),(size_t)254)]=0;
+	      }
+	      }
+	      }
+
+	void science_config::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> active;
+	    }
+	  {  
+	        strncpy(qpix_scheme,s[2]->c_str(),16);
+	        qpix_scheme[15]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> qpix_nside;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> fpix_width;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> total_bandwidth;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> freq_uncertainty;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> fwhm_beamwidth;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> sky_disc_radius;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> observable_sky;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> epoch;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> bary_chirp_window;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> bary_freq_window;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> nonbary_freq_window;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> spike_obs_duration;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> spike_obs_interval;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> gauss_obs_duration;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> gauss_obs_interval;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> pulse_obs_duration;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> pulse_obs_interval;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> triplet_obs_duration;
+	    }
+	  {  
+	        std::istringstream row(*(s[21]));
+	        row >> triplet_obs_interval;
+	    }
+	  {  
+	        std::istringstream row(*(s[22]));
+	        row >> min_spike_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[23]));
+	        row >> min_autocorr_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[24]));
+	        row >> min_gaussian_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[25]));
+	        row >> min_pulse_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[26]));
+	        row >> min_triplet_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[27]));
+	        row >> min_app_version;
+	    }
+	  {  
+	        strncpy(info_xml,s[28]->c_str(),255);
+	        info_xml[254]=0;
+	    }
+	      }
+
+	void science_config::parse(const std::string &s) {
+	      SQL_ROW row(&s,29);
+	      parse(row);
+	      }
 
-template <> const char * const db_table<star>::table_name="star";
-template <> const char * db_table<star>::_search_tag=table_name;
-template <> const int db_table<star>::_nfields=14;
-template <> const char * const db_table<star>::column_names[14]= {"id","object_type","catalog_name","catalog_number","object_name","ra","decl","qpix","v_mag","b_minus_v","parallax","stellar_type","planets","score"};
-
-star::star() :
-    db_table<star>(*this,-1),
-    id(0),
-    catalog_number(0),
-    ra(0),
-    decl(0),
-    qpix(0),
-    v_mag(0),
-    b_minus_v(0),
-    parallax(0),
-    planets(0),
-    score(0) {
-    db_open();
-    object_type[0]=0;
-    catalog_name[0]=0;
-    object_name[0]=0;
-    stellar_type[0]=0;
-}
-
-
-star::star(const star &a) :
-    db_table<star>(*this,-1),
-    id(a.id),
-    catalog_number(a.catalog_number),
-    ra(a.ra),
-    decl(a.decl),
-    qpix(a.qpix),
-    v_mag(a.v_mag),
-    b_minus_v(a.b_minus_v),
-    parallax(a.parallax),
-    planets(a.planets),
-    score(a.score) {
-    db_open();
-    strcpy(object_type,a.object_type);
-    strcpy(catalog_name,a.catalog_name);
-    strcpy(object_name,a.object_name);
-    strcpy(stellar_type,a.stellar_type);
-}
-
-
-star::star(const SQL_ROW &a) :
-    db_table<star>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-star::star(const std::string &s,const char *tag) :
-    db_table<star>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+template <> const char * const db_type<candidate_t>::type_name="candidate_t";
+template <> const char * db_type<candidate_t>::_search_tag=type_name;
+template <> const int db_type<candidate_t>::_nfields=5;
+template <> const char * const db_type<candidate_t>::column_names[5]={"type","id","num_obs","score","is_rfi"};
+
+candidate_t::candidate_t() : 
+	db_type<candidate_t>(*this),
+	type(0),
+	id(0),
+	num_obs(0),
+	score(0),
+	is_rfi(0)
+{
+	db_open();
 }
 
 
-star &star::operator =(const star &a) {
-    if (&a != this) {
-        id=a.id;
-        catalog_number=a.catalog_number;
-        ra=a.ra;
-        decl=a.decl;
-        qpix=a.qpix;
-        v_mag=a.v_mag;
-        b_minus_v=a.b_minus_v;
-        parallax=a.parallax;
-        planets=a.planets;
-        score=a.score;
-        strcpy(object_type,a.object_type);
-        strcpy(catalog_name,a.catalog_name);
-        strcpy(object_name,a.object_name);
-        strcpy(stellar_type,a.stellar_type);
-    }
-    return (*this);
-}
-
-
-std::string star::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<14; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string star::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string star::select_format() const {
-    std::string rv("");
-    for (int i=0; i<13; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string star::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << "'" << object_type << "'";
-    rv << ',';
-    rv << "'" << catalog_name << "'";
-    rv << ',';
-    rv << catalog_number;
-    rv << ',';
-    rv << "'" << object_name << "'";
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << qpix;
-    rv << ',';
-    rv << v_mag;
-    rv << ',';
-    rv << b_minus_v;
-    rv << ',';
-    rv << parallax;
-    rv << ',';
-    rv << "'" << stellar_type << "'";
-    rv << ',';
-    rv << planets;
-    rv << ',';
-    rv << score;
-    return rv.str();
-}
-
-
-std::string star::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    {
-        std::string enc_field=xml_encode_string(object_type,std::min(strlen(object_type),sizeof(object_type)));
-        rv << xml_indent() << "<object_type>";
-        rv << enc_field << "</object_type>\n";
-    }
-    {
-        std::string enc_field=xml_encode_string(catalog_name,std::min(strlen(catalog_name),sizeof(catalog_name)));
-        rv << xml_indent() << "<catalog_name>";
-        rv << enc_field << "</catalog_name>\n";
-    }
-    rv << xml_indent() << "<catalog_number>" << catalog_number << "</catalog_number>\n";
-    {
-        std::string enc_field=xml_encode_string(object_name,std::min(strlen(object_name),sizeof(object_name)));
-        rv << xml_indent() << "<object_name>";
-        rv << enc_field << "</object_name>\n";
-    }
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<qpix>" << qpix << "</qpix>\n";
-    rv << xml_indent() << "<v_mag>" << v_mag << "</v_mag>\n";
-    rv << xml_indent() << "<b_minus_v>" << b_minus_v << "</b_minus_v>\n";
-    rv << xml_indent() << "<parallax>" << parallax << "</parallax>\n";
-    {
-        std::string enc_field=xml_encode_string(stellar_type,std::min(strlen(stellar_type),sizeof(stellar_type)));
-        rv << xml_indent() << "<stellar_type>";
-        rv << enc_field << "</stellar_type>\n";
-    }
-    rv << xml_indent() << "<planets>" << planets << "</planets>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void star::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"object_type",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(object_type,(const char *)&(in.front()),std::min(in.size(),(size_t)16));
-            object_type[std::min(in.size(),(size_t)15)]=0;
-        }
-        if (extract_xml_record(field,"catalog_name",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(catalog_name,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
-            catalog_name[std::min(in.size(),(size_t)63)]=0;
-        }
-        if (extract_xml_record(field,"catalog_number",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> catalog_number;
-        }
-        if (extract_xml_record(field,"object_name",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(object_name,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
-            object_name[std::min(in.size(),(size_t)63)]=0;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"qpix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> qpix;
-        }
-        if (extract_xml_record(field,"v_mag",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> v_mag;
-        }
-        if (extract_xml_record(field,"b_minus_v",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> b_minus_v;
-        }
-        if (extract_xml_record(field,"parallax",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> parallax;
-        }
-        if (extract_xml_record(field,"stellar_type",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(stellar_type,(const char *)&(in.front()),std::min(in.size(),(size_t)32));
-            stellar_type[std::min(in.size(),(size_t)31)]=0;
-        }
-        if (extract_xml_record(field,"planets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> planets;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-    }
-}
-
-void star::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        strncpy(object_type,s[1]->c_str(),16);
-        object_type[15]=0;
-    }
-    {
-        strncpy(catalog_name,s[2]->c_str(),64);
-        catalog_name[63]=0;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> catalog_number;
-    }
-    {
-        strncpy(object_name,s[4]->c_str(),64);
-        object_name[63]=0;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> qpix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> v_mag;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> b_minus_v;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> parallax;
-    }
-    {
-        strncpy(stellar_type,s[11]->c_str(),32);
-        stellar_type[31]=0;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> planets;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> score;
-    }
-}
-
-void star::parse(const std::string &s) {
-    SQL_ROW row(&s,14);
-    parse(row);
+candidate_t::candidate_t(const candidate_t &a) : 
+	db_type<candidate_t>(*this),
+	type(a.type),
+	id(a.id),
+	num_obs(a.num_obs),
+	score(a.score),
+	is_rfi(a.is_rfi)
+{
+	db_open();
 }
 
-template <> const char * const db_table<candidate_count>::table_name="candidate_count";
-template <> const char * db_table<candidate_count>::_search_tag=table_name;
-template <> const int db_table<candidate_count>::_nfields=15;
-template <> const char * const db_table<candidate_count>::column_names[15]= {"id","spikes","gaussians","pulses","triplets","spike_barycentric_multiplets","gaussian_barycentric_multiplets","pulse_barycentric_multiplets","triplet_barycentric_multiplets","spike_nonbarycentric_multiplets","gaussian_nonbarycentric_multiplets","pulse_nonbarycentric_multiplets","triplet_nonbarycentric_multiplets","stars","time_last_updated"};
-
-candidate_count::candidate_count() :
-    db_table<candidate_count>(*this,-1),
-    id(0),
-    spikes(0),
-    gaussians(0),
-    pulses(0),
-    triplets(0),
-    spike_barycentric_multiplets(0),
-    gaussian_barycentric_multiplets(0),
-    pulse_barycentric_multiplets(0),
-    triplet_barycentric_multiplets(0),
-    spike_nonbarycentric_multiplets(0),
-    gaussian_nonbarycentric_multiplets(0),
-    pulse_nonbarycentric_multiplets(0),
-    triplet_nonbarycentric_multiplets(0),
-    stars(0),
-    time_last_updated(0) {
-    db_open();
-}
-
-
-candidate_count::candidate_count(const candidate_count &a) :
-    db_table<candidate_count>(*this,-1),
-    id(a.id),
-    spikes(a.spikes),
-    gaussians(a.gaussians),
-    pulses(a.pulses),
-    triplets(a.triplets),
-    spike_barycentric_multiplets(a.spike_barycentric_multiplets),
-    gaussian_barycentric_multiplets(a.gaussian_barycentric_multiplets),
-    pulse_barycentric_multiplets(a.pulse_barycentric_multiplets),
-    triplet_barycentric_multiplets(a.triplet_barycentric_multiplets),
-    spike_nonbarycentric_multiplets(a.spike_nonbarycentric_multiplets),
-    gaussian_nonbarycentric_multiplets(a.gaussian_nonbarycentric_multiplets),
-    pulse_nonbarycentric_multiplets(a.pulse_nonbarycentric_multiplets),
-    triplet_nonbarycentric_multiplets(a.triplet_nonbarycentric_multiplets),
-    stars(a.stars),
-    time_last_updated(a.time_last_updated) {
-    db_open();
-}
-
-
-candidate_count::candidate_count(const SQL_ROW &a) :
-    db_table<candidate_count>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-candidate_count::candidate_count(const std::string &s,const char *tag) :
-    db_table<candidate_count>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+
+candidate_t::candidate_t(const SQL_ROW &a) : 
+	db_type<candidate_t>(*this)
+{
+	db_open();
+	parse(a);
 }
 
 
-candidate_count &candidate_count::operator =(const candidate_count &a) {
-    if (&a != this) {
-        id=a.id;
-        spikes=a.spikes;
-        gaussians=a.gaussians;
-        pulses=a.pulses;
-        triplets=a.triplets;
-        spike_barycentric_multiplets=a.spike_barycentric_multiplets;
-        gaussian_barycentric_multiplets=a.gaussian_barycentric_multiplets;
-        pulse_barycentric_multiplets=a.pulse_barycentric_multiplets;
-        triplet_barycentric_multiplets=a.triplet_barycentric_multiplets;
-        spike_nonbarycentric_multiplets=a.spike_nonbarycentric_multiplets;
-        gaussian_nonbarycentric_multiplets=a.gaussian_nonbarycentric_multiplets;
-        pulse_nonbarycentric_multiplets=a.pulse_nonbarycentric_multiplets;
-        triplet_nonbarycentric_multiplets=a.triplet_nonbarycentric_multiplets;
-        stars=a.stars;
-        time_last_updated=a.time_last_updated;
-    }
-    return (*this);
-}
-
-
-std::string candidate_count::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<15; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string candidate_count::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string candidate_count::select_format() const {
-    std::string rv("");
-    for (int i=0; i<14; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string candidate_count::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << spikes;
-    rv << ',';
-    rv << gaussians;
-    rv << ',';
-    rv << pulses;
-    rv << ',';
-    rv << triplets;
-    rv << ',';
-    rv << spike_barycentric_multiplets;
-    rv << ',';
-    rv << gaussian_barycentric_multiplets;
-    rv << ',';
-    rv << pulse_barycentric_multiplets;
-    rv << ',';
-    rv << triplet_barycentric_multiplets;
-    rv << ',';
-    rv << spike_nonbarycentric_multiplets;
-    rv << ',';
-    rv << gaussian_nonbarycentric_multiplets;
-    rv << ',';
-    rv << pulse_nonbarycentric_multiplets;
-    rv << ',';
-    rv << triplet_nonbarycentric_multiplets;
-    rv << ',';
-    rv << stars;
-    rv << ',';
-    rv << time_last_updated;
-    return rv.str();
-}
-
-
-std::string candidate_count::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<spikes>" << spikes << "</spikes>\n";
-    rv << xml_indent() << "<gaussians>" << gaussians << "</gaussians>\n";
-    rv << xml_indent() << "<pulses>" << pulses << "</pulses>\n";
-    rv << xml_indent() << "<triplets>" << triplets << "</triplets>\n";
-    rv << xml_indent() << "<spike_barycentric_multiplets>" << spike_barycentric_multiplets << "</spike_barycentric_multiplets>\n";
-    rv << xml_indent() << "<gaussian_barycentric_multiplets>" << gaussian_barycentric_multiplets << "</gaussian_barycentric_multiplets>\n";
-    rv << xml_indent() << "<pulse_barycentric_multiplets>" << pulse_barycentric_multiplets << "</pulse_barycentric_multiplets>\n";
-    rv << xml_indent() << "<triplet_barycentric_multiplets>" << triplet_barycentric_multiplets << "</triplet_barycentric_multiplets>\n";
-    rv << xml_indent() << "<spike_nonbarycentric_multiplets>" << spike_nonbarycentric_multiplets << "</spike_nonbarycentric_multiplets>\n";
-    rv << xml_indent() << "<gaussian_nonbarycentric_multiplets>" << gaussian_nonbarycentric_multiplets << "</gaussian_nonbarycentric_multiplets>\n";
-    rv << xml_indent() << "<pulse_nonbarycentric_multiplets>" << pulse_nonbarycentric_multiplets << "</pulse_nonbarycentric_multiplets>\n";
-    rv << xml_indent() << "<triplet_nonbarycentric_multiplets>" << triplet_nonbarycentric_multiplets << "</triplet_nonbarycentric_multiplets>\n";
-    rv << xml_indent() << "<stars>" << stars << "</stars>\n";
-    rv << xml_indent() << "<time_last_updated>" << time_last_updated << "</time_last_updated>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void candidate_count::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"spikes",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spikes;
-        }
-        if (extract_xml_record(field,"gaussians",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gaussians;
-        }
-        if (extract_xml_record(field,"pulses",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulses;
-        }
-        if (extract_xml_record(field,"triplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplets;
-        }
-        if (extract_xml_record(field,"spike_barycentric_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spike_barycentric_multiplets;
-        }
-        if (extract_xml_record(field,"gaussian_barycentric_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gaussian_barycentric_multiplets;
-        }
-        if (extract_xml_record(field,"pulse_barycentric_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_barycentric_multiplets;
-        }
-        if (extract_xml_record(field,"triplet_barycentric_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_barycentric_multiplets;
-        }
-        if (extract_xml_record(field,"spike_nonbarycentric_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spike_nonbarycentric_multiplets;
-        }
-        if (extract_xml_record(field,"gaussian_nonbarycentric_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gaussian_nonbarycentric_multiplets;
-        }
-        if (extract_xml_record(field,"pulse_nonbarycentric_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_nonbarycentric_multiplets;
-        }
-        if (extract_xml_record(field,"triplet_nonbarycentric_multiplets",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_nonbarycentric_multiplets;
-        }
-        if (extract_xml_record(field,"stars",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> stars;
-        }
-        if (extract_xml_record(field,"time_last_updated",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time_last_updated;
-        }
-    }
-}
-
-void candidate_count::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> spikes;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> gaussians;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> pulses;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> triplets;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> spike_barycentric_multiplets;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> gaussian_barycentric_multiplets;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> pulse_barycentric_multiplets;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> triplet_barycentric_multiplets;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> spike_nonbarycentric_multiplets;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> gaussian_nonbarycentric_multiplets;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> pulse_nonbarycentric_multiplets;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> triplet_nonbarycentric_multiplets;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> stars;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> time_last_updated;
-    }
-}
-
-void candidate_count::parse(const std::string &s) {
-    SQL_ROW row(&s,15);
-    parse(row);
+candidate_t::candidate_t(const std::string &s,const char *tag) : 
+	db_type<candidate_t>(*this)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
-template <> const char * const db_table<tape>::table_name="tape";
-template <> const char * db_table<tape>::_search_tag=table_name;
-template <> const int db_table<tape>::_nfields=8;
-template <> const char * const db_table<tape>::column_names[8]= {"id","name","start_time","last_block_time","last_block_done","missed","tape_quality","beam"};
 
-tape::tape() :
-    db_table<tape>(*this,-1),
-    id(0),
-    start_time(0),
-    last_block_time(0),
-    last_block_done(0),
-    missed(0),
-    tape_quality(0),
-    beam(0) {
-    db_open();
-    name[0]=0;
+candidate_t &candidate_t::operator =(const candidate_t &a) {
+	if (&a != this) {
+		type=a.type;
+		id=a.id;
+		num_obs=a.num_obs;
+		score=a.score;
+		is_rfi=a.is_rfi;
+	}
+	return (*this);
 }
 
 
-tape::tape(const tape &a) :
-    db_table<tape>(*this,-1),
-    id(a.id),
-    start_time(a.start_time),
-    last_block_time(a.last_block_time),
-    last_block_done(a.last_block_done),
-    missed(a.missed),
-    tape_quality(a.tape_quality),
-    beam(a.beam) {
-    db_open();
-    strcpy(name,a.name);
-}
+std::string candidate_t::update_format() const
+{	std::ostringstream rv("");
 
+	rv << "ROW(";
+	for (int i=1;i<5;i++) rv << "?,";
+	rv << "?";
+rv << ")";
 
-tape::tape(const SQL_ROW &a) :
-    db_table<tape>(*this,-1) {
-    db_open();
-    parse(a);
+	return rv.str();
 }
 
 
-tape::tape(const std::string &s,const char *tag) :
-    db_table<tape>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+std::string candidate_t::insert_format() const
+{	return update_format();
 }
 
-
-tape &tape::operator =(const tape &a) {
-    if (&a != this) {
-        id=a.id;
-        start_time=a.start_time;
-        last_block_time=a.last_block_time;
-        last_block_done=a.last_block_done;
-        missed=a.missed;
-        tape_quality=a.tape_quality;
-        beam=a.beam;
-        strcpy(name,a.name);
-    }
-    return (*this);
-}
-
-
-std::string tape::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<8; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string tape::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string tape::select_format() const {
-    std::string rv("");
-    for (int i=0; i<7; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string tape::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << "'" << name << "'";
-    rv << ',';
-    rv << start_time;
-    rv << ',';
-    rv << last_block_time;
-    rv << ',';
-    rv << last_block_done;
-    rv << ',';
-    rv << missed;
-    rv << ',';
-    rv << tape_quality;
-    rv << ',';
-    rv << beam;
-    return rv.str();
-}
-
-
-std::string tape::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    {
-        std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
-        rv << xml_indent() << "<name>";
-        rv << enc_field << "</name>\n";
-    }
-    rv << xml_indent() << "<start_time>" << start_time << "</start_time>\n";
-    rv << xml_indent() << "<last_block_time>" << last_block_time << "</last_block_time>\n";
-    rv << xml_indent() << "<last_block_done>" << last_block_done << "</last_block_done>\n";
-    rv << xml_indent() << "<missed>" << missed << "</missed>\n";
-    rv << xml_indent() << "<tape_quality>" << tape_quality << "</tape_quality>\n";
-    rv << xml_indent() << "<beam>" << beam << "</beam>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void tape::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"name",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)20));
-            name[std::min(in.size(),(size_t)19)]=0;
-        }
-        if (extract_xml_record(field,"start_time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> start_time;
-        }
-        if (extract_xml_record(field,"last_block_time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> last_block_time;
-        }
-        if (extract_xml_record(field,"last_block_done",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> last_block_done;
-        }
-        if (extract_xml_record(field,"missed",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> missed;
-        }
-        if (extract_xml_record(field,"tape_quality",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> tape_quality;
-        }
-        if (extract_xml_record(field,"beam",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> beam;
-        }
-    }
-}
-
-void tape::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        strncpy(name,s[1]->c_str(),20);
-        name[19]=0;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> start_time;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> last_block_time;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> last_block_done;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> missed;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> tape_quality;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> beam;
-    }
-}
-
-void tape::parse(const std::string &s) {
-    SQL_ROW row(&s,8);
-    parse(row);
+std::string candidate_t::select_format() const
+{
+std::string rv("");
+for (int i=0; i<4;i++) rv+="?,";
+rv+="?";
+return rv;
 }
 
-template <> const char * const db_table<settings>::table_name="settings";
-template <> const char * db_table<settings>::_search_tag=table_name;
-template <> const int db_table<settings>::_nfields=6;
-template <> const char * const db_table<settings>::column_names[6]= {"id","active","recorder_cfg","splitter_cfg","analysis_cfg","receiver_cfg"};
+std::string candidate_t::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
 
-settings::settings() :
-    db_table<settings>(*this,-1),
-    id(0),
-    active(0),
-    recorder_cfg(),
-    splitter_cfg(),
-    analysis_cfg(),
-    receiver_cfg() {
-    db_open();
+	rv.precision(14);
+	rv << "ROW(";
+	rv << type;
+	rv << ',';
+	rv << id;
+	rv << ',';
+	rv << num_obs;
+	rv << ',';
+	rv << score;
+	rv << ',';
+	rv << is_rfi;
+	rv << ")";
+	return rv.str();
 }
 
 
-settings::settings(const settings &a) :
-    db_table<settings>(*this,-1),
-    id(a.id),
-    active(a.active),
-    recorder_cfg(a.recorder_cfg),
-    splitter_cfg(a.splitter_cfg),
-    analysis_cfg(a.analysis_cfg),
-    receiver_cfg(a.receiver_cfg) {
-    db_open();
+std::string candidate_t::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	rv << xml_indent() << "<type>" << type << "</type>\n";
+	rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<num_obs>" << num_obs << "</num_obs>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	rv << xml_indent() << "<is_rfi>" << is_rfi << "</is_rfi>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void candidate_t::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"type",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> type;
+	      }
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"num_obs",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_obs;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	    if (extract_xml_record(field,"is_rfi",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> is_rfi;
+	      }
+	      }
+	      }
+
+	void candidate_t::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> type;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> num_obs;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> score;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> is_rfi;
+	    }
+	      }
+
+	void candidate_t::parse(const std::string &s) {
+	      SQL_ROW row(&s,5);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<meta_candidate>::table_name="meta_candidate";
+template <> const char * db_table<meta_candidate>::_search_tag=table_name;
+template <> const int db_table<meta_candidate>::_nfields=32;
+template <> const char * const db_table<meta_candidate>::column_names[32]={"id","version","time_last_updated","num_spikes","num_spike_b_multiplets","best_spike_b_mp_score","num_spike_nb_multiplets","best_spike_nb_mp_score","spike_high_id","num_gaussians","num_gaussian_b_multiplets","best_gaussian_b_mp_score","num_gaussian_nb_multiplets","best_gaussian_nb_mp_score","gaussian_high_id","num_pulses","num_pulse_b_multiplets","best_pulse_b_mp_score","num_pulse_nb_multiplets","best_pulse_nb_mp_ [...]
+
+meta_candidate::meta_candidate() : 
+	db_table<meta_candidate>(*this,-1),
+	id(0),
+	version(0),
+	time_last_updated(0),
+	num_spikes(0),
+	num_spike_b_multiplets(0),
+	best_spike_b_mp_score(0),
+	num_spike_nb_multiplets(0),
+	best_spike_nb_mp_score(0),
+	spike_high_id(0),
+	num_gaussians(0),
+	num_gaussian_b_multiplets(0),
+	best_gaussian_b_mp_score(0),
+	num_gaussian_nb_multiplets(0),
+	best_gaussian_nb_mp_score(0),
+	gaussian_high_id(0),
+	num_pulses(0),
+	num_pulse_b_multiplets(0),
+	best_pulse_b_mp_score(0),
+	num_pulse_nb_multiplets(0),
+	best_pulse_nb_mp_score(0),
+	pulse_high_id(0),
+	num_triplets(0),
+	num_triplet_b_multiplets(0),
+	best_triplet_b_mp_score(0),
+	num_triplet_nb_multiplets(0),
+	best_triplet_nb_mp_score(0),
+	triplet_high_id(0),
+	num_stars(0),
+	best_star_score(0),
+	meta_score(0),
+	rfi_clean(0),
+	state(0)
+{
+	db_open();
+}
+
+
+meta_candidate::meta_candidate(const meta_candidate &a) : 
+	db_table<meta_candidate>(*this,-1),
+	id(a.id),
+	version(a.version),
+	time_last_updated(a.time_last_updated),
+	num_spikes(a.num_spikes),
+	num_spike_b_multiplets(a.num_spike_b_multiplets),
+	best_spike_b_mp_score(a.best_spike_b_mp_score),
+	num_spike_nb_multiplets(a.num_spike_nb_multiplets),
+	best_spike_nb_mp_score(a.best_spike_nb_mp_score),
+	spike_high_id(a.spike_high_id),
+	num_gaussians(a.num_gaussians),
+	num_gaussian_b_multiplets(a.num_gaussian_b_multiplets),
+	best_gaussian_b_mp_score(a.best_gaussian_b_mp_score),
+	num_gaussian_nb_multiplets(a.num_gaussian_nb_multiplets),
+	best_gaussian_nb_mp_score(a.best_gaussian_nb_mp_score),
+	gaussian_high_id(a.gaussian_high_id),
+	num_pulses(a.num_pulses),
+	num_pulse_b_multiplets(a.num_pulse_b_multiplets),
+	best_pulse_b_mp_score(a.best_pulse_b_mp_score),
+	num_pulse_nb_multiplets(a.num_pulse_nb_multiplets),
+	best_pulse_nb_mp_score(a.best_pulse_nb_mp_score),
+	pulse_high_id(a.pulse_high_id),
+	num_triplets(a.num_triplets),
+	num_triplet_b_multiplets(a.num_triplet_b_multiplets),
+	best_triplet_b_mp_score(a.best_triplet_b_mp_score),
+	num_triplet_nb_multiplets(a.num_triplet_nb_multiplets),
+	best_triplet_nb_mp_score(a.best_triplet_nb_mp_score),
+	triplet_high_id(a.triplet_high_id),
+	num_stars(a.num_stars),
+	best_star_score(a.best_star_score),
+	meta_score(a.meta_score),
+	rfi_clean(a.rfi_clean),
+	state(a.state)
+{
+	db_open();
 }
 
 
-settings::settings(const SQL_ROW &a) :
-    db_table<settings>(*this,-1) {
-    db_open();
-    parse(a);
+meta_candidate::meta_candidate(const SQL_ROW &a) : 
+	db_table<meta_candidate>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-settings::settings(const std::string &s,const char *tag) :
-    db_table<settings>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+meta_candidate::meta_candidate(const std::string &s,const char *tag) : 
+	db_table<meta_candidate>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-settings &settings::operator =(const settings &a) {
-    if (&a != this) {
-        id=a.id;
-        active=a.active;
-        recorder_cfg=a.recorder_cfg;
-        splitter_cfg=a.splitter_cfg;
-        analysis_cfg=a.analysis_cfg;
-        receiver_cfg=a.receiver_cfg;
-    }
-    return (*this);
-}
-
-
-std::string settings::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<6; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string settings::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string settings::select_format() const {
-    std::string rv("");
-    for (int i=0; i<5; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string settings::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << active;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << recorder_cfg.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << recorder_cfg.id;
-        }
-    }
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << splitter_cfg.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << splitter_cfg.id;
-        }
-    }
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << analysis_cfg.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << analysis_cfg.id;
-        }
-    }
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << receiver_cfg.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << receiver_cfg.id;
-        }
-    }
-    return rv.str();
-}
-
-
-std::string settings::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<active>" << active << "</active>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << recorder_cfg.print_xml(full_subtables,show_ids,no_refs,"recorder_cfg");
-        } else {
-            rv << xml_indent() << "<recorder_cfg><id>" << recorder_cfg.id << "</id></recorder_cfg>\n";
-        }
-    }
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << splitter_cfg.print_xml(full_subtables,show_ids,no_refs,"splitter_cfg");
-        } else {
-            rv << xml_indent() << "<splitter_cfg><id>" << splitter_cfg.id << "</id></splitter_cfg>\n";
-        }
-    }
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << analysis_cfg.print_xml(full_subtables,show_ids,no_refs,"analysis_cfg");
-        } else {
-            rv << xml_indent() << "<analysis_cfg><id>" << analysis_cfg.id << "</id></analysis_cfg>\n";
-        }
-    }
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << receiver_cfg.print_xml(full_subtables,show_ids,no_refs,"receiver_cfg");
-        } else {
-            rv << xml_indent() << "<receiver_cfg><id>" << receiver_cfg.id << "</id></receiver_cfg>\n";
-        }
-    }
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void settings::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"active",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> active;
-        }
-        if (extract_xml_record(field,"recorder_cfg",sub)) {
-            recorder_cfg.parse_xml(sub,"recorder_cfg");
-        }
-        if (extract_xml_record(field,"splitter_cfg",sub)) {
-            splitter_cfg.parse_xml(sub,"splitter_cfg");
-        }
-        if (extract_xml_record(field,"analysis_cfg",sub)) {
-            analysis_cfg.parse_xml(sub,"analysis_cfg");
-        }
-        if (extract_xml_record(field,"receiver_cfg",sub)) {
-            receiver_cfg.parse_xml(sub,"receiver_cfg");
-        }
-    }
-}
-
-void settings::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> active;
-    }
-    {
-        recorder_cfg.parse(SQL_ROW(s[2],0));
-    }
-    {
-        splitter_cfg.parse(SQL_ROW(s[3],0));
-    }
-    {
-        analysis_cfg.parse(SQL_ROW(s[4],0));
-    }
-    {
-        receiver_cfg.parse(SQL_ROW(s[5],0));
-    }
-}
-
-void settings::parse(const std::string &s) {
-    SQL_ROW row(&s,6);
-    parse(row);
+meta_candidate &meta_candidate::operator =(const meta_candidate &a) {
+	if (&a != this) {
+		id=a.id;
+		version=a.version;
+		time_last_updated=a.time_last_updated;
+		num_spikes=a.num_spikes;
+		num_spike_b_multiplets=a.num_spike_b_multiplets;
+		best_spike_b_mp_score=a.best_spike_b_mp_score;
+		num_spike_nb_multiplets=a.num_spike_nb_multiplets;
+		best_spike_nb_mp_score=a.best_spike_nb_mp_score;
+		spike_high_id=a.spike_high_id;
+		num_gaussians=a.num_gaussians;
+		num_gaussian_b_multiplets=a.num_gaussian_b_multiplets;
+		best_gaussian_b_mp_score=a.best_gaussian_b_mp_score;
+		num_gaussian_nb_multiplets=a.num_gaussian_nb_multiplets;
+		best_gaussian_nb_mp_score=a.best_gaussian_nb_mp_score;
+		gaussian_high_id=a.gaussian_high_id;
+		num_pulses=a.num_pulses;
+		num_pulse_b_multiplets=a.num_pulse_b_multiplets;
+		best_pulse_b_mp_score=a.best_pulse_b_mp_score;
+		num_pulse_nb_multiplets=a.num_pulse_nb_multiplets;
+		best_pulse_nb_mp_score=a.best_pulse_nb_mp_score;
+		pulse_high_id=a.pulse_high_id;
+		num_triplets=a.num_triplets;
+		num_triplet_b_multiplets=a.num_triplet_b_multiplets;
+		best_triplet_b_mp_score=a.best_triplet_b_mp_score;
+		num_triplet_nb_multiplets=a.num_triplet_nb_multiplets;
+		best_triplet_nb_mp_score=a.best_triplet_nb_mp_score;
+		triplet_high_id=a.triplet_high_id;
+		num_stars=a.num_stars;
+		best_star_score=a.best_star_score;
+		meta_score=a.meta_score;
+		rfi_clean=a.rfi_clean;
+		state=a.state;
+	}
+	return (*this);
+}
+
+
+std::string meta_candidate::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<32;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string meta_candidate::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string meta_candidate::select_format() const
+{
+std::string rv("");
+for (int i=0; i<31;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string meta_candidate::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << version;
+	rv << ',';
+	rv << time_last_updated;
+	rv << ',';
+	rv << num_spikes;
+	rv << ',';
+	rv << num_spike_b_multiplets;
+	rv << ',';
+	rv << best_spike_b_mp_score;
+	rv << ',';
+	rv << num_spike_nb_multiplets;
+	rv << ',';
+	rv << best_spike_nb_mp_score;
+	rv << ',';
+	rv << spike_high_id;
+	rv << ',';
+	rv << num_gaussians;
+	rv << ',';
+	rv << num_gaussian_b_multiplets;
+	rv << ',';
+	rv << best_gaussian_b_mp_score;
+	rv << ',';
+	rv << num_gaussian_nb_multiplets;
+	rv << ',';
+	rv << best_gaussian_nb_mp_score;
+	rv << ',';
+	rv << gaussian_high_id;
+	rv << ',';
+	rv << num_pulses;
+	rv << ',';
+	rv << num_pulse_b_multiplets;
+	rv << ',';
+	rv << best_pulse_b_mp_score;
+	rv << ',';
+	rv << num_pulse_nb_multiplets;
+	rv << ',';
+	rv << best_pulse_nb_mp_score;
+	rv << ',';
+	rv << pulse_high_id;
+	rv << ',';
+	rv << num_triplets;
+	rv << ',';
+	rv << num_triplet_b_multiplets;
+	rv << ',';
+	rv << best_triplet_b_mp_score;
+	rv << ',';
+	rv << num_triplet_nb_multiplets;
+	rv << ',';
+	rv << best_triplet_nb_mp_score;
+	rv << ',';
+	rv << triplet_high_id;
+	rv << ',';
+	rv << num_stars;
+	rv << ',';
+	rv << best_star_score;
+	rv << ',';
+	rv << meta_score;
+	rv << ',';
+	rv << rfi_clean;
+	rv << ',';
+	rv << state;
+	return rv.str();
+}
+
+
+std::string meta_candidate::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<version>" << version << "</version>\n";
+	rv << xml_indent() << "<time_last_updated>" << time_last_updated << "</time_last_updated>\n";
+	rv << xml_indent() << "<num_spikes>" << num_spikes << "</num_spikes>\n";
+	rv << xml_indent() << "<num_spike_b_multiplets>" << num_spike_b_multiplets << "</num_spike_b_multiplets>\n";
+	rv << xml_indent() << "<best_spike_b_mp_score>" << best_spike_b_mp_score << "</best_spike_b_mp_score>\n";
+	rv << xml_indent() << "<num_spike_nb_multiplets>" << num_spike_nb_multiplets << "</num_spike_nb_multiplets>\n";
+	rv << xml_indent() << "<best_spike_nb_mp_score>" << best_spike_nb_mp_score << "</best_spike_nb_mp_score>\n";
+	rv << xml_indent() << "<spike_high_id>" << spike_high_id << "</spike_high_id>\n";
+	rv << xml_indent() << "<num_gaussians>" << num_gaussians << "</num_gaussians>\n";
+	rv << xml_indent() << "<num_gaussian_b_multiplets>" << num_gaussian_b_multiplets << "</num_gaussian_b_multiplets>\n";
+	rv << xml_indent() << "<best_gaussian_b_mp_score>" << best_gaussian_b_mp_score << "</best_gaussian_b_mp_score>\n";
+	rv << xml_indent() << "<num_gaussian_nb_multiplets>" << num_gaussian_nb_multiplets << "</num_gaussian_nb_multiplets>\n";
+	rv << xml_indent() << "<best_gaussian_nb_mp_score>" << best_gaussian_nb_mp_score << "</best_gaussian_nb_mp_score>\n";
+	rv << xml_indent() << "<gaussian_high_id>" << gaussian_high_id << "</gaussian_high_id>\n";
+	rv << xml_indent() << "<num_pulses>" << num_pulses << "</num_pulses>\n";
+	rv << xml_indent() << "<num_pulse_b_multiplets>" << num_pulse_b_multiplets << "</num_pulse_b_multiplets>\n";
+	rv << xml_indent() << "<best_pulse_b_mp_score>" << best_pulse_b_mp_score << "</best_pulse_b_mp_score>\n";
+	rv << xml_indent() << "<num_pulse_nb_multiplets>" << num_pulse_nb_multiplets << "</num_pulse_nb_multiplets>\n";
+	rv << xml_indent() << "<best_pulse_nb_mp_score>" << best_pulse_nb_mp_score << "</best_pulse_nb_mp_score>\n";
+	rv << xml_indent() << "<pulse_high_id>" << pulse_high_id << "</pulse_high_id>\n";
+	rv << xml_indent() << "<num_triplets>" << num_triplets << "</num_triplets>\n";
+	rv << xml_indent() << "<num_triplet_b_multiplets>" << num_triplet_b_multiplets << "</num_triplet_b_multiplets>\n";
+	rv << xml_indent() << "<best_triplet_b_mp_score>" << best_triplet_b_mp_score << "</best_triplet_b_mp_score>\n";
+	rv << xml_indent() << "<num_triplet_nb_multiplets>" << num_triplet_nb_multiplets << "</num_triplet_nb_multiplets>\n";
+	rv << xml_indent() << "<best_triplet_nb_mp_score>" << best_triplet_nb_mp_score << "</best_triplet_nb_mp_score>\n";
+	rv << xml_indent() << "<triplet_high_id>" << triplet_high_id << "</triplet_high_id>\n";
+	rv << xml_indent() << "<num_stars>" << num_stars << "</num_stars>\n";
+	rv << xml_indent() << "<best_star_score>" << best_star_score << "</best_star_score>\n";
+	rv << xml_indent() << "<meta_score>" << meta_score << "</meta_score>\n";
+	rv << xml_indent() << "<rfi_clean>" << rfi_clean << "</rfi_clean>\n";
+	rv << xml_indent() << "<state>" << state << "</state>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void meta_candidate::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"version",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> version;
+	      }
+	    if (extract_xml_record(field,"time_last_updated",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time_last_updated;
+	      }
+	    if (extract_xml_record(field,"num_spikes",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_spikes;
+	      }
+	    if (extract_xml_record(field,"num_spike_b_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_spike_b_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_spike_b_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_spike_b_mp_score;
+	      }
+	    if (extract_xml_record(field,"num_spike_nb_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_spike_nb_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_spike_nb_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_spike_nb_mp_score;
+	      }
+	    if (extract_xml_record(field,"spike_high_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spike_high_id;
+	      }
+	    if (extract_xml_record(field,"num_gaussians",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_gaussians;
+	      }
+	    if (extract_xml_record(field,"num_gaussian_b_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_gaussian_b_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_gaussian_b_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_gaussian_b_mp_score;
+	      }
+	    if (extract_xml_record(field,"num_gaussian_nb_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_gaussian_nb_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_gaussian_nb_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_gaussian_nb_mp_score;
+	      }
+	    if (extract_xml_record(field,"gaussian_high_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gaussian_high_id;
+	      }
+	    if (extract_xml_record(field,"num_pulses",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_pulses;
+	      }
+	    if (extract_xml_record(field,"num_pulse_b_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_pulse_b_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_pulse_b_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_pulse_b_mp_score;
+	      }
+	    if (extract_xml_record(field,"num_pulse_nb_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_pulse_nb_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_pulse_nb_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_pulse_nb_mp_score;
+	      }
+	    if (extract_xml_record(field,"pulse_high_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_high_id;
+	      }
+	    if (extract_xml_record(field,"num_triplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_triplets;
+	      }
+	    if (extract_xml_record(field,"num_triplet_b_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_triplet_b_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_triplet_b_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_triplet_b_mp_score;
+	      }
+	    if (extract_xml_record(field,"num_triplet_nb_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_triplet_nb_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_triplet_nb_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_triplet_nb_mp_score;
+	      }
+	    if (extract_xml_record(field,"triplet_high_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_high_id;
+	      }
+	    if (extract_xml_record(field,"num_stars",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_stars;
+	      }
+	    if (extract_xml_record(field,"best_star_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_star_score;
+	      }
+	    if (extract_xml_record(field,"meta_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> meta_score;
+	      }
+	    if (extract_xml_record(field,"rfi_clean",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_clean;
+	      }
+	    if (extract_xml_record(field,"state",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> state;
+	      }
+	      }
+	      }
+
+	void meta_candidate::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> version;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> time_last_updated;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> num_spikes;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> num_spike_b_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> best_spike_b_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> num_spike_nb_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> best_spike_nb_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> spike_high_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> num_gaussians;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> num_gaussian_b_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> best_gaussian_b_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> num_gaussian_nb_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> best_gaussian_nb_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> gaussian_high_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> num_pulses;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> num_pulse_b_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> best_pulse_b_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> num_pulse_nb_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> best_pulse_nb_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> pulse_high_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[21]));
+	        row >> num_triplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[22]));
+	        row >> num_triplet_b_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[23]));
+	        row >> best_triplet_b_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[24]));
+	        row >> num_triplet_nb_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[25]));
+	        row >> best_triplet_nb_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[26]));
+	        row >> triplet_high_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[27]));
+	        row >> num_stars;
+	    }
+	  {  
+	        std::istringstream row(*(s[28]));
+	        row >> best_star_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[29]));
+	        row >> meta_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[30]));
+	        row >> rfi_clean;
+	    }
+	  {  
+	        std::istringstream row(*(s[31]));
+	        row >> state;
+	    }
+	      }
+
+	void meta_candidate::parse(const std::string &s) {
+	      SQL_ROW row(&s,32);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<meta_candidate_tinysky>::table_name="meta_candidate_tinysky";
+template <> const char * db_table<meta_candidate_tinysky>::_search_tag=table_name;
+template <> const int db_table<meta_candidate_tinysky>::_nfields=32;
+template <> const char * const db_table<meta_candidate_tinysky>::column_names[32]={"id","version","time_last_updated","num_spikes","num_spike_b_multiplets","best_spike_b_mp_score","num_spike_nb_multiplets","best_spike_nb_mp_score","spike_high_id","num_gaussians","num_gaussian_b_multiplets","best_gaussian_b_mp_score","num_gaussian_nb_multiplets","best_gaussian_nb_mp_score","gaussian_high_id","num_pulses","num_pulse_b_multiplets","best_pulse_b_mp_score","num_pulse_nb_multiplets","best_puls [...]
+
+meta_candidate_tinysky::meta_candidate_tinysky() : 
+	db_table<meta_candidate_tinysky>(*this,-1),
+	id(0),
+	version(0),
+	time_last_updated(0),
+	num_spikes(0),
+	num_spike_b_multiplets(0),
+	best_spike_b_mp_score(0),
+	num_spike_nb_multiplets(0),
+	best_spike_nb_mp_score(0),
+	spike_high_id(0),
+	num_gaussians(0),
+	num_gaussian_b_multiplets(0),
+	best_gaussian_b_mp_score(0),
+	num_gaussian_nb_multiplets(0),
+	best_gaussian_nb_mp_score(0),
+	gaussian_high_id(0),
+	num_pulses(0),
+	num_pulse_b_multiplets(0),
+	best_pulse_b_mp_score(0),
+	num_pulse_nb_multiplets(0),
+	best_pulse_nb_mp_score(0),
+	pulse_high_id(0),
+	num_triplets(0),
+	num_triplet_b_multiplets(0),
+	best_triplet_b_mp_score(0),
+	num_triplet_nb_multiplets(0),
+	best_triplet_nb_mp_score(0),
+	triplet_high_id(0),
+	num_stars(0),
+	best_star_score(0),
+	meta_score(0),
+	rfi_clean(0),
+	state(0)
+{
+	db_open();
+}
+
+
+meta_candidate_tinysky::meta_candidate_tinysky(const meta_candidate_tinysky &a) : 
+	db_table<meta_candidate_tinysky>(*this,-1),
+	id(a.id),
+	version(a.version),
+	time_last_updated(a.time_last_updated),
+	num_spikes(a.num_spikes),
+	num_spike_b_multiplets(a.num_spike_b_multiplets),
+	best_spike_b_mp_score(a.best_spike_b_mp_score),
+	num_spike_nb_multiplets(a.num_spike_nb_multiplets),
+	best_spike_nb_mp_score(a.best_spike_nb_mp_score),
+	spike_high_id(a.spike_high_id),
+	num_gaussians(a.num_gaussians),
+	num_gaussian_b_multiplets(a.num_gaussian_b_multiplets),
+	best_gaussian_b_mp_score(a.best_gaussian_b_mp_score),
+	num_gaussian_nb_multiplets(a.num_gaussian_nb_multiplets),
+	best_gaussian_nb_mp_score(a.best_gaussian_nb_mp_score),
+	gaussian_high_id(a.gaussian_high_id),
+	num_pulses(a.num_pulses),
+	num_pulse_b_multiplets(a.num_pulse_b_multiplets),
+	best_pulse_b_mp_score(a.best_pulse_b_mp_score),
+	num_pulse_nb_multiplets(a.num_pulse_nb_multiplets),
+	best_pulse_nb_mp_score(a.best_pulse_nb_mp_score),
+	pulse_high_id(a.pulse_high_id),
+	num_triplets(a.num_triplets),
+	num_triplet_b_multiplets(a.num_triplet_b_multiplets),
+	best_triplet_b_mp_score(a.best_triplet_b_mp_score),
+	num_triplet_nb_multiplets(a.num_triplet_nb_multiplets),
+	best_triplet_nb_mp_score(a.best_triplet_nb_mp_score),
+	triplet_high_id(a.triplet_high_id),
+	num_stars(a.num_stars),
+	best_star_score(a.best_star_score),
+	meta_score(a.meta_score),
+	rfi_clean(a.rfi_clean),
+	state(a.state)
+{
+	db_open();
 }
 
-template <> const char * const db_table<workunit_grp>::table_name="workunit_grp";
-template <> const char * db_table<workunit_grp>::_search_tag=table_name;
-template <> const int db_table<workunit_grp>::_nfields=11;
-template <> const char * const db_table<workunit_grp>::column_names[11]= {"id","tape_info","name","data_desc","receiver_cfg","recorder_cfg","splitter_cfg","analysis_cfg","sb_id","iq_modified","alfa_filter_bank"};
 
-workunit_grp::workunit_grp() :
-    db_table<workunit_grp>(*this,-1),
-    id(0),
-    tape_info(),
-    data_desc(),
-    receiver_cfg(),
-    recorder_cfg(),
-    splitter_cfg(),
-    analysis_cfg(),
-    sb_id(0),
-    iq_modified(0),
-    alfa_filter_bank(0) {
-    db_open();
-    name[0]=0;
+meta_candidate_tinysky::meta_candidate_tinysky(const SQL_ROW &a) : 
+	db_table<meta_candidate_tinysky>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-workunit_grp::workunit_grp(const workunit_grp &a) :
-    db_table<workunit_grp>(*this,-1),
-    id(a.id),
-    tape_info(a.tape_info),
-    data_desc(a.data_desc),
-    receiver_cfg(a.receiver_cfg),
-    recorder_cfg(a.recorder_cfg),
-    splitter_cfg(a.splitter_cfg),
-    analysis_cfg(a.analysis_cfg),
-    sb_id(a.sb_id),
-    iq_modified(a.iq_modified),
-    alfa_filter_bank(a.alfa_filter_bank) {
-    db_open();
-    strcpy(name,a.name);
+meta_candidate_tinysky::meta_candidate_tinysky(const std::string &s,const char *tag) : 
+	db_table<meta_candidate_tinysky>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+meta_candidate_tinysky &meta_candidate_tinysky::operator =(const meta_candidate_tinysky &a) {
+	if (&a != this) {
+		id=a.id;
+		version=a.version;
+		time_last_updated=a.time_last_updated;
+		num_spikes=a.num_spikes;
+		num_spike_b_multiplets=a.num_spike_b_multiplets;
+		best_spike_b_mp_score=a.best_spike_b_mp_score;
+		num_spike_nb_multiplets=a.num_spike_nb_multiplets;
+		best_spike_nb_mp_score=a.best_spike_nb_mp_score;
+		spike_high_id=a.spike_high_id;
+		num_gaussians=a.num_gaussians;
+		num_gaussian_b_multiplets=a.num_gaussian_b_multiplets;
+		best_gaussian_b_mp_score=a.best_gaussian_b_mp_score;
+		num_gaussian_nb_multiplets=a.num_gaussian_nb_multiplets;
+		best_gaussian_nb_mp_score=a.best_gaussian_nb_mp_score;
+		gaussian_high_id=a.gaussian_high_id;
+		num_pulses=a.num_pulses;
+		num_pulse_b_multiplets=a.num_pulse_b_multiplets;
+		best_pulse_b_mp_score=a.best_pulse_b_mp_score;
+		num_pulse_nb_multiplets=a.num_pulse_nb_multiplets;
+		best_pulse_nb_mp_score=a.best_pulse_nb_mp_score;
+		pulse_high_id=a.pulse_high_id;
+		num_triplets=a.num_triplets;
+		num_triplet_b_multiplets=a.num_triplet_b_multiplets;
+		best_triplet_b_mp_score=a.best_triplet_b_mp_score;
+		num_triplet_nb_multiplets=a.num_triplet_nb_multiplets;
+		best_triplet_nb_mp_score=a.best_triplet_nb_mp_score;
+		triplet_high_id=a.triplet_high_id;
+		num_stars=a.num_stars;
+		best_star_score=a.best_star_score;
+		meta_score=a.meta_score;
+		rfi_clean=a.rfi_clean;
+		state=a.state;
+	}
+	return (*this);
+}
+
+
+std::string meta_candidate_tinysky::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<32;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string meta_candidate_tinysky::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string meta_candidate_tinysky::select_format() const
+{
+std::string rv("");
+for (int i=0; i<31;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string meta_candidate_tinysky::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << version;
+	rv << ',';
+	rv << time_last_updated;
+	rv << ',';
+	rv << num_spikes;
+	rv << ',';
+	rv << num_spike_b_multiplets;
+	rv << ',';
+	rv << best_spike_b_mp_score;
+	rv << ',';
+	rv << num_spike_nb_multiplets;
+	rv << ',';
+	rv << best_spike_nb_mp_score;
+	rv << ',';
+	rv << spike_high_id;
+	rv << ',';
+	rv << num_gaussians;
+	rv << ',';
+	rv << num_gaussian_b_multiplets;
+	rv << ',';
+	rv << best_gaussian_b_mp_score;
+	rv << ',';
+	rv << num_gaussian_nb_multiplets;
+	rv << ',';
+	rv << best_gaussian_nb_mp_score;
+	rv << ',';
+	rv << gaussian_high_id;
+	rv << ',';
+	rv << num_pulses;
+	rv << ',';
+	rv << num_pulse_b_multiplets;
+	rv << ',';
+	rv << best_pulse_b_mp_score;
+	rv << ',';
+	rv << num_pulse_nb_multiplets;
+	rv << ',';
+	rv << best_pulse_nb_mp_score;
+	rv << ',';
+	rv << pulse_high_id;
+	rv << ',';
+	rv << num_triplets;
+	rv << ',';
+	rv << num_triplet_b_multiplets;
+	rv << ',';
+	rv << best_triplet_b_mp_score;
+	rv << ',';
+	rv << num_triplet_nb_multiplets;
+	rv << ',';
+	rv << best_triplet_nb_mp_score;
+	rv << ',';
+	rv << triplet_high_id;
+	rv << ',';
+	rv << num_stars;
+	rv << ',';
+	rv << best_star_score;
+	rv << ',';
+	rv << meta_score;
+	rv << ',';
+	rv << rfi_clean;
+	rv << ',';
+	rv << state;
+	return rv.str();
+}
+
+
+std::string meta_candidate_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<version>" << version << "</version>\n";
+	rv << xml_indent() << "<time_last_updated>" << time_last_updated << "</time_last_updated>\n";
+	rv << xml_indent() << "<num_spikes>" << num_spikes << "</num_spikes>\n";
+	rv << xml_indent() << "<num_spike_b_multiplets>" << num_spike_b_multiplets << "</num_spike_b_multiplets>\n";
+	rv << xml_indent() << "<best_spike_b_mp_score>" << best_spike_b_mp_score << "</best_spike_b_mp_score>\n";
+	rv << xml_indent() << "<num_spike_nb_multiplets>" << num_spike_nb_multiplets << "</num_spike_nb_multiplets>\n";
+	rv << xml_indent() << "<best_spike_nb_mp_score>" << best_spike_nb_mp_score << "</best_spike_nb_mp_score>\n";
+	rv << xml_indent() << "<spike_high_id>" << spike_high_id << "</spike_high_id>\n";
+	rv << xml_indent() << "<num_gaussians>" << num_gaussians << "</num_gaussians>\n";
+	rv << xml_indent() << "<num_gaussian_b_multiplets>" << num_gaussian_b_multiplets << "</num_gaussian_b_multiplets>\n";
+	rv << xml_indent() << "<best_gaussian_b_mp_score>" << best_gaussian_b_mp_score << "</best_gaussian_b_mp_score>\n";
+	rv << xml_indent() << "<num_gaussian_nb_multiplets>" << num_gaussian_nb_multiplets << "</num_gaussian_nb_multiplets>\n";
+	rv << xml_indent() << "<best_gaussian_nb_mp_score>" << best_gaussian_nb_mp_score << "</best_gaussian_nb_mp_score>\n";
+	rv << xml_indent() << "<gaussian_high_id>" << gaussian_high_id << "</gaussian_high_id>\n";
+	rv << xml_indent() << "<num_pulses>" << num_pulses << "</num_pulses>\n";
+	rv << xml_indent() << "<num_pulse_b_multiplets>" << num_pulse_b_multiplets << "</num_pulse_b_multiplets>\n";
+	rv << xml_indent() << "<best_pulse_b_mp_score>" << best_pulse_b_mp_score << "</best_pulse_b_mp_score>\n";
+	rv << xml_indent() << "<num_pulse_nb_multiplets>" << num_pulse_nb_multiplets << "</num_pulse_nb_multiplets>\n";
+	rv << xml_indent() << "<best_pulse_nb_mp_score>" << best_pulse_nb_mp_score << "</best_pulse_nb_mp_score>\n";
+	rv << xml_indent() << "<pulse_high_id>" << pulse_high_id << "</pulse_high_id>\n";
+	rv << xml_indent() << "<num_triplets>" << num_triplets << "</num_triplets>\n";
+	rv << xml_indent() << "<num_triplet_b_multiplets>" << num_triplet_b_multiplets << "</num_triplet_b_multiplets>\n";
+	rv << xml_indent() << "<best_triplet_b_mp_score>" << best_triplet_b_mp_score << "</best_triplet_b_mp_score>\n";
+	rv << xml_indent() << "<num_triplet_nb_multiplets>" << num_triplet_nb_multiplets << "</num_triplet_nb_multiplets>\n";
+	rv << xml_indent() << "<best_triplet_nb_mp_score>" << best_triplet_nb_mp_score << "</best_triplet_nb_mp_score>\n";
+	rv << xml_indent() << "<triplet_high_id>" << triplet_high_id << "</triplet_high_id>\n";
+	rv << xml_indent() << "<num_stars>" << num_stars << "</num_stars>\n";
+	rv << xml_indent() << "<best_star_score>" << best_star_score << "</best_star_score>\n";
+	rv << xml_indent() << "<meta_score>" << meta_score << "</meta_score>\n";
+	rv << xml_indent() << "<rfi_clean>" << rfi_clean << "</rfi_clean>\n";
+	rv << xml_indent() << "<state>" << state << "</state>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void meta_candidate_tinysky::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"version",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> version;
+	      }
+	    if (extract_xml_record(field,"time_last_updated",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time_last_updated;
+	      }
+	    if (extract_xml_record(field,"num_spikes",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_spikes;
+	      }
+	    if (extract_xml_record(field,"num_spike_b_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_spike_b_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_spike_b_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_spike_b_mp_score;
+	      }
+	    if (extract_xml_record(field,"num_spike_nb_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_spike_nb_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_spike_nb_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_spike_nb_mp_score;
+	      }
+	    if (extract_xml_record(field,"spike_high_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spike_high_id;
+	      }
+	    if (extract_xml_record(field,"num_gaussians",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_gaussians;
+	      }
+	    if (extract_xml_record(field,"num_gaussian_b_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_gaussian_b_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_gaussian_b_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_gaussian_b_mp_score;
+	      }
+	    if (extract_xml_record(field,"num_gaussian_nb_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_gaussian_nb_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_gaussian_nb_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_gaussian_nb_mp_score;
+	      }
+	    if (extract_xml_record(field,"gaussian_high_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gaussian_high_id;
+	      }
+	    if (extract_xml_record(field,"num_pulses",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_pulses;
+	      }
+	    if (extract_xml_record(field,"num_pulse_b_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_pulse_b_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_pulse_b_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_pulse_b_mp_score;
+	      }
+	    if (extract_xml_record(field,"num_pulse_nb_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_pulse_nb_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_pulse_nb_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_pulse_nb_mp_score;
+	      }
+	    if (extract_xml_record(field,"pulse_high_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_high_id;
+	      }
+	    if (extract_xml_record(field,"num_triplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_triplets;
+	      }
+	    if (extract_xml_record(field,"num_triplet_b_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_triplet_b_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_triplet_b_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_triplet_b_mp_score;
+	      }
+	    if (extract_xml_record(field,"num_triplet_nb_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_triplet_nb_multiplets;
+	      }
+	    if (extract_xml_record(field,"best_triplet_nb_mp_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_triplet_nb_mp_score;
+	      }
+	    if (extract_xml_record(field,"triplet_high_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_high_id;
+	      }
+	    if (extract_xml_record(field,"num_stars",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_stars;
+	      }
+	    if (extract_xml_record(field,"best_star_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> best_star_score;
+	      }
+	    if (extract_xml_record(field,"meta_score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> meta_score;
+	      }
+	    if (extract_xml_record(field,"rfi_clean",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_clean;
+	      }
+	    if (extract_xml_record(field,"state",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> state;
+	      }
+	      }
+	      }
+
+	void meta_candidate_tinysky::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> version;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> time_last_updated;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> num_spikes;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> num_spike_b_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> best_spike_b_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> num_spike_nb_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> best_spike_nb_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> spike_high_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> num_gaussians;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> num_gaussian_b_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> best_gaussian_b_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> num_gaussian_nb_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> best_gaussian_nb_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> gaussian_high_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> num_pulses;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> num_pulse_b_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> best_pulse_b_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> num_pulse_nb_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> best_pulse_nb_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> pulse_high_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[21]));
+	        row >> num_triplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[22]));
+	        row >> num_triplet_b_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[23]));
+	        row >> best_triplet_b_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[24]));
+	        row >> num_triplet_nb_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[25]));
+	        row >> best_triplet_nb_mp_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[26]));
+	        row >> triplet_high_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[27]));
+	        row >> num_stars;
+	    }
+	  {  
+	        std::istringstream row(*(s[28]));
+	        row >> best_star_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[29]));
+	        row >> meta_score;
+	    }
+	  {  
+	        std::istringstream row(*(s[30]));
+	        row >> rfi_clean;
+	    }
+	  {  
+	        std::istringstream row(*(s[31]));
+	        row >> state;
+	    }
+	      }
+
+	void meta_candidate_tinysky::parse(const std::string &s) {
+	      SQL_ROW row(&s,32);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<multiplet>::table_name="multiplet";
+template <> const char * db_table<multiplet>::_search_tag=table_name;
+template <> const int db_table<multiplet>::_nfields=25;
+template <> const char * const db_table<multiplet>::column_names[25]={"id","version","signal_type","mp_type","qpix","freq_win","mean_ra","mean_decl","ra_stddev","decl_stddev","mean_angular_distance","angular_distance_stddev","mean_frequency","frequency_stddev","mean_chirp","chirp_stddev","mean_period","period_stddev","mean_snr","snr_stddev","mean_threshold","threshold_stddev","score","num_detections","signal_ids"};
+
+multiplet::multiplet() : 
+	db_table<multiplet>(*this,-1),
+	id(0),
+	version(0),
+	signal_type(0),
+	mp_type(0),
+	qpix(0),
+	freq_win(0),
+	mean_ra(0),
+	mean_decl(0),
+	ra_stddev(0),
+	decl_stddev(0),
+	mean_angular_distance(0),
+	angular_distance_stddev(0),
+	mean_frequency(0),
+	frequency_stddev(0),
+	mean_chirp(0),
+	chirp_stddev(0),
+	mean_period(0),
+	period_stddev(0),
+	mean_snr(0),
+	snr_stddev(0),
+	mean_threshold(0),
+	threshold_stddev(0),
+	score(0),
+	num_detections(0),
+	signal_ids((sqlint8_t *)0,0,_x_csv)
+{
+	db_open();
+}
+
+
+multiplet::multiplet(const multiplet &a) : 
+	db_table<multiplet>(*this,-1),
+	id(a.id),
+	version(a.version),
+	signal_type(a.signal_type),
+	mp_type(a.mp_type),
+	qpix(a.qpix),
+	freq_win(a.freq_win),
+	mean_ra(a.mean_ra),
+	mean_decl(a.mean_decl),
+	ra_stddev(a.ra_stddev),
+	decl_stddev(a.decl_stddev),
+	mean_angular_distance(a.mean_angular_distance),
+	angular_distance_stddev(a.angular_distance_stddev),
+	mean_frequency(a.mean_frequency),
+	frequency_stddev(a.frequency_stddev),
+	mean_chirp(a.mean_chirp),
+	chirp_stddev(a.chirp_stddev),
+	mean_period(a.mean_period),
+	period_stddev(a.period_stddev),
+	mean_snr(a.mean_snr),
+	snr_stddev(a.snr_stddev),
+	mean_threshold(a.mean_threshold),
+	threshold_stddev(a.threshold_stddev),
+	score(a.score),
+	num_detections(a.num_detections),
+	signal_ids(a.signal_ids)
+{
+	db_open();
 }
 
 
-workunit_grp::workunit_grp(const SQL_ROW &a) :
-    db_table<workunit_grp>(*this,-1) {
-    db_open();
-    parse(a);
+multiplet::multiplet(const SQL_ROW &a) : 
+	db_table<multiplet>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-workunit_grp::workunit_grp(const std::string &s,const char *tag) :
-    db_table<workunit_grp>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+multiplet::multiplet(const std::string &s,const char *tag) : 
+	db_table<multiplet>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-workunit_grp &workunit_grp::operator =(const workunit_grp &a) {
-    if (&a != this) {
-        id=a.id;
-        tape_info=a.tape_info;
-        data_desc=a.data_desc;
-        receiver_cfg=a.receiver_cfg;
-        recorder_cfg=a.recorder_cfg;
-        splitter_cfg=a.splitter_cfg;
-        analysis_cfg=a.analysis_cfg;
-        sb_id=a.sb_id;
-        iq_modified=a.iq_modified;
-        alfa_filter_bank=a.alfa_filter_bank;
-        strcpy(name,a.name);
-    }
-    return (*this);
-}
-
-
-std::string workunit_grp::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<11; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string workunit_grp::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string workunit_grp::select_format() const {
-    std::string rv("");
-    for (int i=0; i<10; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string workunit_grp::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << tape_info.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << tape_info.id;
-        }
-    }
-    rv << ',';
-    rv << "'" << name << "'";
-    rv << ',';
-    rv << data_desc.print(full_subtables,show_ids,no_refs);
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << receiver_cfg.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << receiver_cfg.id;
-        }
-    }
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << recorder_cfg.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << recorder_cfg.id;
-        }
-    }
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << splitter_cfg.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << splitter_cfg.id;
-        }
-    }
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << analysis_cfg.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << analysis_cfg.id;
-        }
-    }
-    rv << ',';
-    rv << sb_id;
-    rv << ',';
-    rv << iq_modified;
-    rv << ',';
-    rv << alfa_filter_bank;
-    return rv.str();
-}
-
-
-std::string workunit_grp::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << tape_info.print_xml(full_subtables,show_ids,no_refs,"tape_info");
-        } else {
-            rv << xml_indent() << "<tape_info><id>" << tape_info.id << "</id></tape_info>\n";
-        }
-    }
-    {
-        std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
-        rv << xml_indent() << "<name>";
-        rv << enc_field << "</name>\n";
-    }
-    rv << data_desc.print_xml(full_subtables,show_ids,no_refs,"data_desc");
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << receiver_cfg.print_xml(full_subtables,show_ids,no_refs,"receiver_cfg");
-        } else {
-            rv << xml_indent() << "<receiver_cfg><id>" << receiver_cfg.id << "</id></receiver_cfg>\n";
-        }
-    }
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << recorder_cfg.print_xml(full_subtables,show_ids,no_refs,"recorder_cfg");
-        } else {
-            rv << xml_indent() << "<recorder_cfg><id>" << recorder_cfg.id << "</id></recorder_cfg>\n";
-        }
-    }
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << splitter_cfg.print_xml(full_subtables,show_ids,no_refs,"splitter_cfg");
-        } else {
-            rv << xml_indent() << "<splitter_cfg><id>" << splitter_cfg.id << "</id></splitter_cfg>\n";
-        }
-    }
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << analysis_cfg.print_xml(full_subtables,show_ids,no_refs,"analysis_cfg");
-        } else {
-            rv << xml_indent() << "<analysis_cfg><id>" << analysis_cfg.id << "</id></analysis_cfg>\n";
-        }
-    }
-    rv << xml_indent() << "<sb_id>" << sb_id << "</sb_id>\n";
-    rv << xml_indent() << "<iq_modified>" << iq_modified << "</iq_modified>\n";
-    rv << xml_indent() << "<alfa_filter_bank>" << alfa_filter_bank << "</alfa_filter_bank>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void workunit_grp::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"tape_info",sub)) {
-            tape_info.parse_xml(sub,"tape_info");
-        }
-        if (extract_xml_record(field,"name",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
-            name[std::min(in.size(),(size_t)63)]=0;
-        }
-        if (extract_xml_record(field,"data_desc",sub)) {
-            data_desc.parse_xml(sub,"data_desc");
-        }
-        if (extract_xml_record(field,"receiver_cfg",sub)) {
-            receiver_cfg.parse_xml(sub,"receiver_cfg");
-        }
-        if (extract_xml_record(field,"recorder_cfg",sub)) {
-            recorder_cfg.parse_xml(sub,"recorder_cfg");
-        }
-        if (extract_xml_record(field,"splitter_cfg",sub)) {
-            splitter_cfg.parse_xml(sub,"splitter_cfg");
-        }
-        if (extract_xml_record(field,"analysis_cfg",sub)) {
-            analysis_cfg.parse_xml(sub,"analysis_cfg");
-        }
-        if (extract_xml_record(field,"sb_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> sb_id;
-        }
-        if (extract_xml_record(field,"iq_modified",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> iq_modified;
-        }
-        if (extract_xml_record(field,"alfa_filter_bank",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> alfa_filter_bank;
-        }
-    }
-}
-
-void workunit_grp::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        tape_info.parse(SQL_ROW(s[1],0));
-    }
-    {
-        strncpy(name,s[2]->c_str(),64);
-        name[63]=0;
-    }
-    {
-        data_desc.parse(SQL_ROW(s[3],0));
-    }
-    {
-        receiver_cfg.parse(SQL_ROW(s[4],0));
-    }
-    {
-        recorder_cfg.parse(SQL_ROW(s[5],0));
-    }
-    {
-        splitter_cfg.parse(SQL_ROW(s[6],0));
-    }
-    {
-        analysis_cfg.parse(SQL_ROW(s[7],0));
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> sb_id;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> iq_modified;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> alfa_filter_bank;
-    }
-}
-
-void workunit_grp::parse(const std::string &s) {
-    SQL_ROW row(&s,11);
-    parse(row);
+multiplet &multiplet::operator =(const multiplet &a) {
+	if (&a != this) {
+		id=a.id;
+		version=a.version;
+		signal_type=a.signal_type;
+		mp_type=a.mp_type;
+		qpix=a.qpix;
+		freq_win=a.freq_win;
+		mean_ra=a.mean_ra;
+		mean_decl=a.mean_decl;
+		ra_stddev=a.ra_stddev;
+		decl_stddev=a.decl_stddev;
+		mean_angular_distance=a.mean_angular_distance;
+		angular_distance_stddev=a.angular_distance_stddev;
+		mean_frequency=a.mean_frequency;
+		frequency_stddev=a.frequency_stddev;
+		mean_chirp=a.mean_chirp;
+		chirp_stddev=a.chirp_stddev;
+		mean_period=a.mean_period;
+		period_stddev=a.period_stddev;
+		mean_snr=a.mean_snr;
+		snr_stddev=a.snr_stddev;
+		mean_threshold=a.mean_threshold;
+		threshold_stddev=a.threshold_stddev;
+		score=a.score;
+		num_detections=a.num_detections;
+		{
+		  signal_ids.clear();
+		  std::vector<sqlint8_t>::const_iterator i(a.signal_ids.begin());
+		  for (;i!=a.signal_ids.end();i++) {
+		    signal_ids.push_back(*i); 
+		  }
+		}
+	}
+	return (*this);
+}
+
+
+std::string multiplet::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<25;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string multiplet::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string multiplet::select_format() const
+{
+std::string rv("");
+for (int i=0; i<24;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string multiplet::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << version;
+	rv << ',';
+	rv << signal_type;
+	rv << ',';
+	rv << mp_type;
+	rv << ',';
+	rv << qpix;
+	rv << ',';
+	rv << freq_win;
+	rv << ',';
+	rv << mean_ra;
+	rv << ',';
+	rv << mean_decl;
+	rv << ',';
+	rv << ra_stddev;
+	rv << ',';
+	rv << decl_stddev;
+	rv << ',';
+	rv << mean_angular_distance;
+	rv << ',';
+	rv << angular_distance_stddev;
+	rv << ',';
+	rv << mean_frequency;
+	rv << ',';
+	rv << frequency_stddev;
+	rv << ',';
+	rv << mean_chirp;
+	rv << ',';
+	rv << chirp_stddev;
+	rv << ',';
+	rv << mean_period;
+	rv << ',';
+	rv << period_stddev;
+	rv << ',';
+	rv << mean_snr;
+	rv << ',';
+	rv << snr_stddev;
+	rv << ',';
+	rv << mean_threshold;
+	rv << ',';
+	rv << threshold_stddev;
+	rv << ',';
+	rv << score;
+	rv << ',';
+	rv << num_detections;
+	rv << ',';
+	rv << "LIST {";
+	{
+	std::vector<sqlint8_t>::const_iterator p=signal_ids.begin();
+	for (;p<signal_ids.end();p++) {
+	  rv << *p;
+	  if (p != signal_ids.end()-1) {
+	    rv << ',';
+	  } else {
+	    rv << "}";
+	  }
+	}
+	}
+	return rv.str();
+}
+
+
+std::string multiplet::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<version>" << version << "</version>\n";
+	rv << xml_indent() << "<signal_type>" << signal_type << "</signal_type>\n";
+	rv << xml_indent() << "<mp_type>" << mp_type << "</mp_type>\n";
+	rv << xml_indent() << "<qpix>" << qpix << "</qpix>\n";
+	rv << xml_indent() << "<freq_win>" << freq_win << "</freq_win>\n";
+	rv << xml_indent() << "<mean_ra>" << mean_ra << "</mean_ra>\n";
+	rv << xml_indent() << "<mean_decl>" << mean_decl << "</mean_decl>\n";
+	rv << xml_indent() << "<ra_stddev>" << ra_stddev << "</ra_stddev>\n";
+	rv << xml_indent() << "<decl_stddev>" << decl_stddev << "</decl_stddev>\n";
+	rv << xml_indent() << "<mean_angular_distance>" << mean_angular_distance << "</mean_angular_distance>\n";
+	rv << xml_indent() << "<angular_distance_stddev>" << angular_distance_stddev << "</angular_distance_stddev>\n";
+	rv << xml_indent() << "<mean_frequency>" << mean_frequency << "</mean_frequency>\n";
+	rv << xml_indent() << "<frequency_stddev>" << frequency_stddev << "</frequency_stddev>\n";
+	rv << xml_indent() << "<mean_chirp>" << mean_chirp << "</mean_chirp>\n";
+	rv << xml_indent() << "<chirp_stddev>" << chirp_stddev << "</chirp_stddev>\n";
+	rv << xml_indent() << "<mean_period>" << mean_period << "</mean_period>\n";
+	rv << xml_indent() << "<period_stddev>" << period_stddev << "</period_stddev>\n";
+	rv << xml_indent() << "<mean_snr>" << mean_snr << "</mean_snr>\n";
+	rv << xml_indent() << "<snr_stddev>" << snr_stddev << "</snr_stddev>\n";
+	rv << xml_indent() << "<mean_threshold>" << mean_threshold << "</mean_threshold>\n";
+	rv << xml_indent() << "<threshold_stddev>" << threshold_stddev << "</threshold_stddev>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	rv << xml_indent() << "<num_detections>" << num_detections << "</num_detections>\n";
+	if (signal_ids.size()) {
+	  rv << xml_indent() << "<signal_ids";
+	  {
+	    std::string enc_string=signal_ids.print_xml();
+	    rv << " length=" << enc_string.size() << " encoding=\"" << xml_encoding_names[signal_ids.encoding] << "\">" ;
+	    rv << enc_string;
+	  }
+}
+	rv << "</signal_ids>\n"; 
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void multiplet::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"version",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> version;
+	      }
+	    if (extract_xml_record(field,"signal_type",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> signal_type;
+	      }
+	    if (extract_xml_record(field,"mp_type",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mp_type;
+	      }
+	    if (extract_xml_record(field,"qpix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> qpix;
+	      }
+	    if (extract_xml_record(field,"freq_win",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq_win;
+	      }
+	    if (extract_xml_record(field,"mean_ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_ra;
+	      }
+	    if (extract_xml_record(field,"mean_decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_decl;
+	      }
+	    if (extract_xml_record(field,"ra_stddev",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra_stddev;
+	      }
+	    if (extract_xml_record(field,"decl_stddev",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl_stddev;
+	      }
+	    if (extract_xml_record(field,"mean_angular_distance",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_angular_distance;
+	      }
+	    if (extract_xml_record(field,"angular_distance_stddev",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> angular_distance_stddev;
+	      }
+	    if (extract_xml_record(field,"mean_frequency",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_frequency;
+	      }
+	    if (extract_xml_record(field,"frequency_stddev",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> frequency_stddev;
+	      }
+	    if (extract_xml_record(field,"mean_chirp",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_chirp;
+	      }
+	    if (extract_xml_record(field,"chirp_stddev",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_stddev;
+	      }
+	    if (extract_xml_record(field,"mean_period",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_period;
+	      }
+	    if (extract_xml_record(field,"period_stddev",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> period_stddev;
+	      }
+	    if (extract_xml_record(field,"mean_snr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_snr;
+	      }
+	    if (extract_xml_record(field,"snr_stddev",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> snr_stddev;
+	      }
+	    if (extract_xml_record(field,"mean_threshold",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_threshold;
+	      }
+	    if (extract_xml_record(field,"threshold_stddev",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> threshold_stddev;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	    if (extract_xml_record(field,"num_detections",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> num_detections;
+	      }
+	    signal_ids.clear();
+	    if (extract_xml_record(field,"signal_ids",sub)) {
+	      pos=sub.find(">");
+	      do {
+	        if (pos!=std::string::npos) {
+	          do { pos++; } while ((sub[pos]=='\n') || (sub[pos]==','));
+	          std::istringstream in(std::string(sub.c_str()+pos)); 
+	          sqlint8_t tmp;
+	          in >> tmp;
+	          signal_ids.push_back(tmp);
+	        }
+	      } while ((pos=sub.find(",",pos)) != std::string::npos); 
+	    }
+	      }
+	      }
+
+	void multiplet::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> version;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> signal_type;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mp_type;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> qpix;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> freq_win;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> mean_ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> mean_decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> ra_stddev;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> decl_stddev;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> mean_angular_distance;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> angular_distance_stddev;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> mean_frequency;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> frequency_stddev;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> mean_chirp;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> chirp_stddev;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> mean_period;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> period_stddev;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> mean_snr;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> snr_stddev;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> mean_threshold;
+	    }
+	  {  
+	        std::istringstream row(*(s[21]));
+	        row >> threshold_stddev;
+	    }
+	  {  
+	        std::istringstream row(*(s[22]));
+	        row >> score;
+	    }
+	  {  
+	        std::istringstream row(*(s[23]));
+	        row >> num_detections;
+	    }
+	  {  
+	  std::string::size_type p,q;
+	  int i;
+	    signal_ids.clear();
+	      SQL_ROW tmp(s[24]); 
+	        for (i=0;i<tmp.argc();i++) {
+	          std::istringstream in(*(tmp[i]));
+	          sqlint8_t tmp0;
+	          in >> tmp0;
+	          signal_ids.push_back(tmp0);
+	      }
+	    }
+	      }
+
+	void multiplet::parse(const std::string &s) {
+	      SQL_ROW row(&s,25);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<star>::table_name="star";
+template <> const char * db_table<star>::_search_tag=table_name;
+template <> const int db_table<star>::_nfields=14;
+template <> const char * const db_table<star>::column_names[14]={"id","object_type","catalog_name","catalog_number","object_name","ra","decl","qpix","v_mag","b_minus_v","parallax","stellar_type","planets","score"};
+
+star::star() : 
+	db_table<star>(*this,-1),
+	id(0),
+	catalog_number(0),
+	ra(0),
+	decl(0),
+	qpix(0),
+	v_mag(0),
+	b_minus_v(0),
+	parallax(0),
+	planets(0),
+	score(0)
+{
+	db_open();
+	object_type[0]=0;
+	catalog_name[0]=0;
+	object_name[0]=0;
+	stellar_type[0]=0;
+}
+
+
+star::star(const star &a) : 
+	db_table<star>(*this,-1),
+	id(a.id),
+	catalog_number(a.catalog_number),
+	ra(a.ra),
+	decl(a.decl),
+	qpix(a.qpix),
+	v_mag(a.v_mag),
+	b_minus_v(a.b_minus_v),
+	parallax(a.parallax),
+	planets(a.planets),
+	score(a.score)
+{
+	db_open();
+	strcpy(object_type,a.object_type);
+	strcpy(catalog_name,a.catalog_name);
+	strcpy(object_name,a.object_name);
+	strcpy(stellar_type,a.stellar_type);
 }
 
-template <> const char * const db_table<workunit_header>::table_name="workunit_header";
-template <> const char * db_table<workunit_header>::_search_tag=table_name;
-template <> const int db_table<workunit_header>::_nfields=5;
-template <> const char * const db_table<workunit_header>::column_names[5]= {"id","name","group_info","subband_desc","sb_id"};
 
-workunit_header::workunit_header() :
-    db_table<workunit_header>(*this,-1),
-    id(0),
-    group_info(),
-    subband_desc(),
-    sb_id(0) {
-    db_open();
-    name[0]=0;
+star::star(const SQL_ROW &a) : 
+	db_table<star>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-workunit_header::workunit_header(const workunit_header &a) :
-    db_table<workunit_header>(*this,-1),
-    id(a.id),
-    group_info(a.group_info),
-    subband_desc(a.subband_desc),
-    sb_id(a.sb_id) {
-    db_open();
-    strcpy(name,a.name);
+star::star(const std::string &s,const char *tag) : 
+	db_table<star>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-workunit_header::workunit_header(const SQL_ROW &a) :
-    db_table<workunit_header>(*this,-1) {
-    db_open();
-    parse(a);
+star &star::operator =(const star &a) {
+	if (&a != this) {
+		id=a.id;
+		catalog_number=a.catalog_number;
+		ra=a.ra;
+		decl=a.decl;
+		qpix=a.qpix;
+		v_mag=a.v_mag;
+		b_minus_v=a.b_minus_v;
+		parallax=a.parallax;
+		planets=a.planets;
+		score=a.score;
+	strcpy(object_type,a.object_type);
+	strcpy(catalog_name,a.catalog_name);
+	strcpy(object_name,a.object_name);
+	strcpy(stellar_type,a.stellar_type);
+	}
+	return (*this);
 }
 
 
-workunit_header::workunit_header(const std::string &s,const char *tag) :
-    db_table<workunit_header>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+std::string star::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<14;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-workunit_header &workunit_header::operator =(const workunit_header &a) {
-    if (&a != this) {
-        id=a.id;
-        group_info=a.group_info;
-        subband_desc=a.subband_desc;
-        sb_id=a.sb_id;
-        strcpy(name,a.name);
-    }
-    return (*this);
-}
-
-
-std::string workunit_header::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<5; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string workunit_header::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string workunit_header::select_format() const {
-    std::string rv("");
-    for (int i=0; i<4; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string workunit_header::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << "'" << name << "'";
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << group_info.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << group_info.id;
-        }
-    }
-    rv << ',';
-    rv << subband_desc.print(full_subtables,show_ids,no_refs);
-    rv << ',';
-    rv << sb_id;
-    return rv.str();
-}
-
-
-std::string workunit_header::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    {
-        std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
-        rv << xml_indent() << "<name>";
-        rv << enc_field << "</name>\n";
-    }
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << group_info.print_xml(full_subtables,show_ids,no_refs,"group_info");
-        } else {
-            rv << xml_indent() << "<group_info><id>" << group_info.id << "</id></group_info>\n";
-        }
-    }
-    rv << subband_desc.print_xml(full_subtables,show_ids,no_refs,"subband_desc");
-    rv << xml_indent() << "<sb_id>" << sb_id << "</sb_id>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void workunit_header::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"name",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
-            name[std::min(in.size(),(size_t)63)]=0;
-        }
-        if (extract_xml_record(field,"group_info",sub)) {
-            group_info.parse_xml(sub,"group_info");
-        }
-        if (extract_xml_record(field,"subband_desc",sub)) {
-            subband_desc.parse_xml(sub,"subband_desc");
-        }
-        if (extract_xml_record(field,"sb_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> sb_id;
-        }
-    }
-}
-
-void workunit_header::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        strncpy(name,s[1]->c_str(),64);
-        name[63]=0;
-    }
-    {
-        group_info.parse(SQL_ROW(s[2],0));
-    }
-    {
-        subband_desc.parse(SQL_ROW(s[3],0));
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> sb_id;
-    }
-}
-
-void workunit_header::parse(const std::string &s) {
-    SQL_ROW row(&s,5);
-    parse(row);
+std::string star::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
-template <> const char * const db_table<result>::table_name="result";
-template <> const char * db_table<result>::_search_tag=table_name;
-template <> const int db_table<result>::_nfields=10;
-template <> const char * const db_table<result>::column_names[10]= {"id","boinc_result","wuid","received","hostid","versionid","return_code","overflow","reserved","sb_id"};
+std::string star::select_format() const
+{
+std::string rv("");
+for (int i=0; i<13;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string star::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << "'" << object_type << "'";
+	rv << ',';
+	rv << "'" << catalog_name << "'";
+	rv << ',';
+	rv << catalog_number;
+	rv << ',';
+	rv << "'" << object_name << "'";
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << qpix;
+	rv << ',';
+	rv << v_mag;
+	rv << ',';
+	rv << b_minus_v;
+	rv << ',';
+	rv << parallax;
+	rv << ',';
+	rv << "'" << stellar_type << "'";
+	rv << ',';
+	rv << planets;
+	rv << ',';
+	rv << score;
+	return rv.str();
+}
+
+
+std::string star::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	{
+	  std::string enc_field=xml_encode_string(object_type,std::min(strlen(object_type),sizeof(object_type)));
+	  rv << xml_indent() << "<object_type>";
+	  rv << enc_field << "</object_type>\n";
+	}
+	{
+	  std::string enc_field=xml_encode_string(catalog_name,std::min(strlen(catalog_name),sizeof(catalog_name)));
+	  rv << xml_indent() << "<catalog_name>";
+	  rv << enc_field << "</catalog_name>\n";
+	}
+	rv << xml_indent() << "<catalog_number>" << catalog_number << "</catalog_number>\n";
+	{
+	  std::string enc_field=xml_encode_string(object_name,std::min(strlen(object_name),sizeof(object_name)));
+	  rv << xml_indent() << "<object_name>";
+	  rv << enc_field << "</object_name>\n";
+	}
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<qpix>" << qpix << "</qpix>\n";
+	rv << xml_indent() << "<v_mag>" << v_mag << "</v_mag>\n";
+	rv << xml_indent() << "<b_minus_v>" << b_minus_v << "</b_minus_v>\n";
+	rv << xml_indent() << "<parallax>" << parallax << "</parallax>\n";
+	{
+	  std::string enc_field=xml_encode_string(stellar_type,std::min(strlen(stellar_type),sizeof(stellar_type)));
+	  rv << xml_indent() << "<stellar_type>";
+	  rv << enc_field << "</stellar_type>\n";
+	}
+	rv << xml_indent() << "<planets>" << planets << "</planets>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void star::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"object_type",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(object_type,(const char *)&(in.front()),std::min(in.size(),(size_t)16));
+	        object_type[std::min(in.size(),(size_t)15)]=0;
+	      }
+	    if (extract_xml_record(field,"catalog_name",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(catalog_name,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
+	        catalog_name[std::min(in.size(),(size_t)63)]=0;
+	      }
+	    if (extract_xml_record(field,"catalog_number",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> catalog_number;
+	      }
+	    if (extract_xml_record(field,"object_name",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(object_name,(const char *)&(in.front()),std::min(in.size(),(size_t)64));
+	        object_name[std::min(in.size(),(size_t)63)]=0;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"qpix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> qpix;
+	      }
+	    if (extract_xml_record(field,"v_mag",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> v_mag;
+	      }
+	    if (extract_xml_record(field,"b_minus_v",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> b_minus_v;
+	      }
+	    if (extract_xml_record(field,"parallax",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> parallax;
+	      }
+	    if (extract_xml_record(field,"stellar_type",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(stellar_type,(const char *)&(in.front()),std::min(in.size(),(size_t)32));
+	        stellar_type[std::min(in.size(),(size_t)31)]=0;
+	      }
+	    if (extract_xml_record(field,"planets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> planets;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	      }
+	      }
+
+	void star::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        strncpy(object_type,s[1]->c_str(),16);
+	        object_type[15]=0;
+	    }
+	  {  
+	        strncpy(catalog_name,s[2]->c_str(),64);
+	        catalog_name[63]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> catalog_number;
+	    }
+	  {  
+	        strncpy(object_name,s[4]->c_str(),64);
+	        object_name[63]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> qpix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> v_mag;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> b_minus_v;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> parallax;
+	    }
+	  {  
+	        strncpy(stellar_type,s[11]->c_str(),32);
+	        stellar_type[31]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> planets;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> score;
+	    }
+	      }
+
+	void star::parse(const std::string &s) {
+	      SQL_ROW row(&s,14);
+	      parse(row);
+	      }
 
-result::result() :
-    db_table<result>(*this,-1),
-    id(0),
-    boinc_result(0),
-    wuid(),
-    received(0),
-    hostid(0),
-    versionid(0),
-    return_code(0),
-    overflow(0),
-    reserved(0),
-    sb_id(0) {
-    db_open();
+template <> const char * const db_table<candidate_count>::table_name="candidate_count";
+template <> const char * db_table<candidate_count>::_search_tag=table_name;
+template <> const int db_table<candidate_count>::_nfields=15;
+template <> const char * const db_table<candidate_count>::column_names[15]={"id","spikes","gaussians","pulses","triplets","spike_barycentric_multiplets","gaussian_barycentric_multiplets","pulse_barycentric_multiplets","triplet_barycentric_multiplets","spike_nonbarycentric_multiplets","gaussian_nonbarycentric_multiplets","pulse_nonbarycentric_multiplets","triplet_nonbarycentric_multiplets","stars","time_last_updated"};
+
+candidate_count::candidate_count() : 
+	db_table<candidate_count>(*this,-1),
+	id(0),
+	spikes(0),
+	gaussians(0),
+	pulses(0),
+	triplets(0),
+	spike_barycentric_multiplets(0),
+	gaussian_barycentric_multiplets(0),
+	pulse_barycentric_multiplets(0),
+	triplet_barycentric_multiplets(0),
+	spike_nonbarycentric_multiplets(0),
+	gaussian_nonbarycentric_multiplets(0),
+	pulse_nonbarycentric_multiplets(0),
+	triplet_nonbarycentric_multiplets(0),
+	stars(0),
+	time_last_updated(0)
+{
+	db_open();
+}
+
+
+candidate_count::candidate_count(const candidate_count &a) : 
+	db_table<candidate_count>(*this,-1),
+	id(a.id),
+	spikes(a.spikes),
+	gaussians(a.gaussians),
+	pulses(a.pulses),
+	triplets(a.triplets),
+	spike_barycentric_multiplets(a.spike_barycentric_multiplets),
+	gaussian_barycentric_multiplets(a.gaussian_barycentric_multiplets),
+	pulse_barycentric_multiplets(a.pulse_barycentric_multiplets),
+	triplet_barycentric_multiplets(a.triplet_barycentric_multiplets),
+	spike_nonbarycentric_multiplets(a.spike_nonbarycentric_multiplets),
+	gaussian_nonbarycentric_multiplets(a.gaussian_nonbarycentric_multiplets),
+	pulse_nonbarycentric_multiplets(a.pulse_nonbarycentric_multiplets),
+	triplet_nonbarycentric_multiplets(a.triplet_nonbarycentric_multiplets),
+	stars(a.stars),
+	time_last_updated(a.time_last_updated)
+{
+	db_open();
 }
 
 
-result::result(const result &a) :
-    db_table<result>(*this,-1),
-    id(a.id),
-    boinc_result(a.boinc_result),
-    wuid(a.wuid),
-    received(a.received),
-    hostid(a.hostid),
-    versionid(a.versionid),
-    return_code(a.return_code),
-    overflow(a.overflow),
-    reserved(a.reserved),
-    sb_id(a.sb_id) {
-    db_open();
+candidate_count::candidate_count(const SQL_ROW &a) : 
+	db_table<candidate_count>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-result::result(const SQL_ROW &a) :
-    db_table<result>(*this,-1) {
-    db_open();
-    parse(a);
+candidate_count::candidate_count(const std::string &s,const char *tag) : 
+	db_table<candidate_count>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-result::result(const std::string &s,const char *tag) :
-    db_table<result>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+candidate_count &candidate_count::operator =(const candidate_count &a) {
+	if (&a != this) {
+		id=a.id;
+		spikes=a.spikes;
+		gaussians=a.gaussians;
+		pulses=a.pulses;
+		triplets=a.triplets;
+		spike_barycentric_multiplets=a.spike_barycentric_multiplets;
+		gaussian_barycentric_multiplets=a.gaussian_barycentric_multiplets;
+		pulse_barycentric_multiplets=a.pulse_barycentric_multiplets;
+		triplet_barycentric_multiplets=a.triplet_barycentric_multiplets;
+		spike_nonbarycentric_multiplets=a.spike_nonbarycentric_multiplets;
+		gaussian_nonbarycentric_multiplets=a.gaussian_nonbarycentric_multiplets;
+		pulse_nonbarycentric_multiplets=a.pulse_nonbarycentric_multiplets;
+		triplet_nonbarycentric_multiplets=a.triplet_nonbarycentric_multiplets;
+		stars=a.stars;
+		time_last_updated=a.time_last_updated;
+	}
+	return (*this);
 }
 
 
-result &result::operator =(const result &a) {
-    if (&a != this) {
-        id=a.id;
-        boinc_result=a.boinc_result;
-        wuid=a.wuid;
-        received=a.received;
-        hostid=a.hostid;
-        versionid=a.versionid;
-        return_code=a.return_code;
-        overflow=a.overflow;
-        reserved=a.reserved;
-        sb_id=a.sb_id;
-    }
-    return (*this);
-}
-
-
-std::string result::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<10; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string result::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string result::select_format() const {
-    std::string rv("");
-    for (int i=0; i<9; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string result::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << boinc_result;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << wuid.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << wuid.id;
-        }
-    }
-    rv << ',';
-    rv << received;
-    rv << ',';
-    rv << hostid;
-    rv << ',';
-    rv << versionid;
-    rv << ',';
-    rv << return_code;
-    rv << ',';
-    rv << overflow;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << sb_id;
-    return rv.str();
-}
-
-
-std::string result::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<boinc_result>" << boinc_result << "</boinc_result>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << wuid.print_xml(full_subtables,show_ids,no_refs,"wuid");
-        } else {
-            rv << xml_indent() << "<wuid><id>" << wuid.id << "</id></wuid>\n";
-        }
-    }
-    rv << xml_indent() << "<received>" << received << "</received>\n";
-    rv << xml_indent() << "<hostid>" << hostid << "</hostid>\n";
-    rv << xml_indent() << "<versionid>" << versionid << "</versionid>\n";
-    rv << xml_indent() << "<return_code>" << return_code << "</return_code>\n";
-    rv << xml_indent() << "<overflow>" << overflow << "</overflow>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<sb_id>" << sb_id << "</sb_id>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void result::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"boinc_result",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> boinc_result;
-        }
-        if (extract_xml_record(field,"wuid",sub)) {
-            wuid.parse_xml(sub,"wuid");
-        }
-        if (extract_xml_record(field,"received",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> received;
-        }
-        if (extract_xml_record(field,"hostid",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> hostid;
-        }
-        if (extract_xml_record(field,"versionid",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> versionid;
-        }
-        if (extract_xml_record(field,"return_code",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> return_code;
-        }
-        if (extract_xml_record(field,"overflow",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> overflow;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"sb_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> sb_id;
-        }
-    }
-}
-
-void result::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> boinc_result;
-    }
-    {
-        wuid.parse(SQL_ROW(s[2],0));
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> received;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> hostid;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> versionid;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> return_code;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> overflow;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> sb_id;
-    }
-}
-
-void result::parse(const std::string &s) {
-    SQL_ROW row(&s,10);
-    parse(row);
-}
+std::string candidate_count::update_format() const
+{	std::ostringstream rv("");
 
-template <> const char * const db_table<triplet>::table_name="triplet";
-template <> const char * db_table<triplet>::_search_tag=table_name;
-template <> const int db_table<triplet>::_nfields=17;
-template <> const char * const db_table<triplet>::column_names[17]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period"};
-
-triplet::triplet() :
-    db_table<triplet>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0),
-    period(0) {
-    db_open();
-}
-
-
-triplet::triplet(const triplet &a) :
-    db_table<triplet>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved),
-    period(a.period) {
-    db_open();
-}
-
-
-triplet::triplet(const SQL_ROW &a) :
-    db_table<triplet>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-triplet::triplet(const std::string &s,const char *tag) :
-    db_table<triplet>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+	for (int i=2;i<15;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-triplet &triplet::operator =(const triplet &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-        period=a.period;
-    }
-    return (*this);
-}
-
-
-std::string triplet::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<17; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string triplet::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string triplet::select_format() const {
-    std::string rv("");
-    for (int i=0; i<16; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string triplet::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << period;
-    return rv.str();
-}
-
-
-std::string triplet::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<period>" << period << "</period>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void triplet::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"period",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> period;
-        }
-    }
-}
-
-void triplet::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> period;
-    }
-}
-
-void triplet::parse(const std::string &s) {
-    SQL_ROW row(&s,17);
-    parse(row);
+std::string candidate_count::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
-template <> const char * const db_table<triplet_small>::table_name="triplet_small";
-template <> const char * db_table<triplet_small>::_search_tag=table_name;
-template <> const int db_table<triplet_small>::_nfields=17;
-template <> const char * const db_table<triplet_small>::column_names[17]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period"};
-
-triplet_small::triplet_small() :
-    db_table<triplet_small>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0),
-    period(0) {
-    db_open();
-}
-
-
-triplet_small::triplet_small(const triplet_small &a) :
-    db_table<triplet_small>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved),
-    period(a.period) {
-    db_open();
-}
-
-
-triplet_small::triplet_small(const SQL_ROW &a) :
-    db_table<triplet_small>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-triplet_small::triplet_small(const std::string &s,const char *tag) :
-    db_table<triplet_small>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+std::string candidate_count::select_format() const
+{
+std::string rv("");
+for (int i=0; i<14;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string candidate_count::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << spikes;
+	rv << ',';
+	rv << gaussians;
+	rv << ',';
+	rv << pulses;
+	rv << ',';
+	rv << triplets;
+	rv << ',';
+	rv << spike_barycentric_multiplets;
+	rv << ',';
+	rv << gaussian_barycentric_multiplets;
+	rv << ',';
+	rv << pulse_barycentric_multiplets;
+	rv << ',';
+	rv << triplet_barycentric_multiplets;
+	rv << ',';
+	rv << spike_nonbarycentric_multiplets;
+	rv << ',';
+	rv << gaussian_nonbarycentric_multiplets;
+	rv << ',';
+	rv << pulse_nonbarycentric_multiplets;
+	rv << ',';
+	rv << triplet_nonbarycentric_multiplets;
+	rv << ',';
+	rv << stars;
+	rv << ',';
+	rv << time_last_updated;
+	return rv.str();
+}
+
+
+std::string candidate_count::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<spikes>" << spikes << "</spikes>\n";
+	rv << xml_indent() << "<gaussians>" << gaussians << "</gaussians>\n";
+	rv << xml_indent() << "<pulses>" << pulses << "</pulses>\n";
+	rv << xml_indent() << "<triplets>" << triplets << "</triplets>\n";
+	rv << xml_indent() << "<spike_barycentric_multiplets>" << spike_barycentric_multiplets << "</spike_barycentric_multiplets>\n";
+	rv << xml_indent() << "<gaussian_barycentric_multiplets>" << gaussian_barycentric_multiplets << "</gaussian_barycentric_multiplets>\n";
+	rv << xml_indent() << "<pulse_barycentric_multiplets>" << pulse_barycentric_multiplets << "</pulse_barycentric_multiplets>\n";
+	rv << xml_indent() << "<triplet_barycentric_multiplets>" << triplet_barycentric_multiplets << "</triplet_barycentric_multiplets>\n";
+	rv << xml_indent() << "<spike_nonbarycentric_multiplets>" << spike_nonbarycentric_multiplets << "</spike_nonbarycentric_multiplets>\n";
+	rv << xml_indent() << "<gaussian_nonbarycentric_multiplets>" << gaussian_nonbarycentric_multiplets << "</gaussian_nonbarycentric_multiplets>\n";
+	rv << xml_indent() << "<pulse_nonbarycentric_multiplets>" << pulse_nonbarycentric_multiplets << "</pulse_nonbarycentric_multiplets>\n";
+	rv << xml_indent() << "<triplet_nonbarycentric_multiplets>" << triplet_nonbarycentric_multiplets << "</triplet_nonbarycentric_multiplets>\n";
+	rv << xml_indent() << "<stars>" << stars << "</stars>\n";
+	rv << xml_indent() << "<time_last_updated>" << time_last_updated << "</time_last_updated>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void candidate_count::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"spikes",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spikes;
+	      }
+	    if (extract_xml_record(field,"gaussians",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gaussians;
+	      }
+	    if (extract_xml_record(field,"pulses",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulses;
+	      }
+	    if (extract_xml_record(field,"triplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplets;
+	      }
+	    if (extract_xml_record(field,"spike_barycentric_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spike_barycentric_multiplets;
+	      }
+	    if (extract_xml_record(field,"gaussian_barycentric_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gaussian_barycentric_multiplets;
+	      }
+	    if (extract_xml_record(field,"pulse_barycentric_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_barycentric_multiplets;
+	      }
+	    if (extract_xml_record(field,"triplet_barycentric_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_barycentric_multiplets;
+	      }
+	    if (extract_xml_record(field,"spike_nonbarycentric_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spike_nonbarycentric_multiplets;
+	      }
+	    if (extract_xml_record(field,"gaussian_nonbarycentric_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gaussian_nonbarycentric_multiplets;
+	      }
+	    if (extract_xml_record(field,"pulse_nonbarycentric_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_nonbarycentric_multiplets;
+	      }
+	    if (extract_xml_record(field,"triplet_nonbarycentric_multiplets",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_nonbarycentric_multiplets;
+	      }
+	    if (extract_xml_record(field,"stars",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> stars;
+	      }
+	    if (extract_xml_record(field,"time_last_updated",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time_last_updated;
+	      }
+	      }
+	      }
+
+	void candidate_count::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> spikes;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> gaussians;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> pulses;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> triplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> spike_barycentric_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> gaussian_barycentric_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> pulse_barycentric_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> triplet_barycentric_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> spike_nonbarycentric_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> gaussian_nonbarycentric_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> pulse_nonbarycentric_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> triplet_nonbarycentric_multiplets;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> stars;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> time_last_updated;
+	    }
+	      }
+
+	void candidate_count::parse(const std::string &s) {
+	      SQL_ROW row(&s,15);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<tape>::table_name="tape";
+template <> const char * db_table<tape>::_search_tag=table_name;
+template <> const int db_table<tape>::_nfields=8;
+template <> const char * const db_table<tape>::column_names[8]={"id","name","start_time","last_block_time","last_block_done","missed","tape_quality","beam"};
+
+tape::tape() : 
+	db_table<tape>(*this,-1),
+	id(0),
+	start_time(0),
+	last_block_time(0),
+	last_block_done(0),
+	missed(0),
+	tape_quality(0),
+	beam(0)
+{
+	db_open();
+	name[0]=0;
 }
 
 
-triplet_small &triplet_small::operator =(const triplet_small &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-        period=a.period;
-    }
-    return (*this);
-}
-
-
-std::string triplet_small::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<17; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string triplet_small::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string triplet_small::select_format() const {
-    std::string rv("");
-    for (int i=0; i<16; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string triplet_small::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << period;
-    return rv.str();
-}
-
-
-std::string triplet_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<period>" << period << "</period>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void triplet_small::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"period",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> period;
-        }
-    }
-}
-
-void triplet_small::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> period;
-    }
-}
-
-void triplet_small::parse(const std::string &s) {
-    SQL_ROW row(&s,17);
-    parse(row);
+tape::tape(const tape &a) : 
+	db_table<tape>(*this,-1),
+	id(a.id),
+	start_time(a.start_time),
+	last_block_time(a.last_block_time),
+	last_block_done(a.last_block_done),
+	missed(a.missed),
+	tape_quality(a.tape_quality),
+	beam(a.beam)
+{
+	db_open();
+	strcpy(name,a.name);
 }
 
-template <> const char * const db_table<gaussian>::table_name="gaussian";
-template <> const char * db_table<gaussian>::_search_tag=table_name;
-template <> const int db_table<gaussian>::_nfields=22;
-template <> const char * const db_table<gaussian>::column_names[22]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","sigma","chisqr","null_chisqr","score","max_power","pot"};
-
-gaussian::gaussian() :
-    db_table<gaussian>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0),
-    sigma(0),
-    chisqr(0),
-    null_chisqr(0),
-    score(0),
-    max_power(0),
-    pot((unsigned char *)0,0,_x_csv) {
-    db_open();
-}
-
-
-gaussian::gaussian(const gaussian &a) :
-    db_table<gaussian>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved),
-    sigma(a.sigma),
-    chisqr(a.chisqr),
-    null_chisqr(a.null_chisqr),
-    score(a.score),
-    max_power(a.max_power),
-    pot(a.pot) {
-    db_open();
-}
-
-
-gaussian::gaussian(const SQL_ROW &a) :
-    db_table<gaussian>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-gaussian::gaussian(const std::string &s,const char *tag) :
-    db_table<gaussian>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+
+tape::tape(const SQL_ROW &a) : 
+	db_table<tape>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-gaussian &gaussian::operator =(const gaussian &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-        sigma=a.sigma;
-        chisqr=a.chisqr;
-        null_chisqr=a.null_chisqr;
-        score=a.score;
-        max_power=a.max_power;
-        pot=a.pot;
-    }
-    return (*this);
-}
-
-
-std::string gaussian::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<22; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string gaussian::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string gaussian::select_format() const {
-    std::string rv("");
-    for (int i=0; i<21; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string gaussian::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << sigma;
-    rv << ',';
-    rv << chisqr;
-    rv << ',';
-    rv << null_chisqr;
-    rv << ',';
-    rv << score;
-    rv << ',';
-    rv << max_power;
-    rv << ',';
-    rv << "<BYTE len=" << std::max(pot.size()*2,(size_t)1) << ">" << pot.print_hex() ;
-    return rv.str();
-}
-
-
-std::string gaussian::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<sigma>" << sigma << "</sigma>\n";
-    rv << xml_indent() << "<chisqr>" << chisqr << "</chisqr>\n";
-    rv << xml_indent() << "<null_chisqr>" << null_chisqr << "</null_chisqr>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    rv << xml_indent() << "<max_power>" << max_power << "</max_power>\n";
-    if (pot.size()) {
-        std::string enc_field=xml_encode_string(pot,pot.encoding);
-        rv << xml_indent() << "<pot length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[pot.encoding] << "\">";
-        rv << enc_field << "</pot>\n";
-    }
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void gaussian::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"sigma",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> sigma;
-        }
-        if (extract_xml_record(field,"chisqr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chisqr;
-        }
-        if (extract_xml_record(field,"null_chisqr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> null_chisqr;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-        if (extract_xml_record(field,"max_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_power;
-        }
-        if (extract_xml_record(field,"pot",sub)) {
-            std::istringstream in(sub.c_str());
-            in >> pot;
-        }
-    }
-}
-
-void gaussian::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> sigma;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> chisqr;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> null_chisqr;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> score;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> max_power;
-    }
-    {
-        pot=sqlblob<unsigned char>(*(s[21]));
-    }
-}
-
-void gaussian::parse(const std::string &s) {
-    SQL_ROW row(&s,22);
-    parse(row);
+tape::tape(const std::string &s,const char *tag) : 
+	db_table<tape>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+tape &tape::operator =(const tape &a) {
+	if (&a != this) {
+		id=a.id;
+		start_time=a.start_time;
+		last_block_time=a.last_block_time;
+		last_block_done=a.last_block_done;
+		missed=a.missed;
+		tape_quality=a.tape_quality;
+		beam=a.beam;
+	strcpy(name,a.name);
+	}
+	return (*this);
+}
+
+
+std::string tape::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<8;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string tape::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string tape::select_format() const
+{
+std::string rv("");
+for (int i=0; i<7;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string tape::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << "'" << name << "'";
+	rv << ',';
+	rv << start_time;
+	rv << ',';
+	rv << last_block_time;
+	rv << ',';
+	rv << last_block_done;
+	rv << ',';
+	rv << missed;
+	rv << ',';
+	rv << tape_quality;
+	rv << ',';
+	rv << beam;
+	return rv.str();
+}
+
+
+std::string tape::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	{
+	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
+	  rv << xml_indent() << "<name>";
+	  rv << enc_field << "</name>\n";
+	}
+	rv << xml_indent() << "<start_time>" << start_time << "</start_time>\n";
+	rv << xml_indent() << "<last_block_time>" << last_block_time << "</last_block_time>\n";
+	rv << xml_indent() << "<last_block_done>" << last_block_done << "</last_block_done>\n";
+	rv << xml_indent() << "<missed>" << missed << "</missed>\n";
+	rv << xml_indent() << "<tape_quality>" << tape_quality << "</tape_quality>\n";
+	rv << xml_indent() << "<beam>" << beam << "</beam>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void tape::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"name",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)128));
+	        name[std::min(in.size(),(size_t)127)]=0;
+	      }
+	    if (extract_xml_record(field,"start_time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> start_time;
+	      }
+	    if (extract_xml_record(field,"last_block_time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> last_block_time;
+	      }
+	    if (extract_xml_record(field,"last_block_done",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> last_block_done;
+	      }
+	    if (extract_xml_record(field,"missed",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> missed;
+	      }
+	    if (extract_xml_record(field,"tape_quality",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> tape_quality;
+	      }
+	    if (extract_xml_record(field,"beam",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> beam;
+	      }
+	      }
+	      }
+
+	void tape::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        strncpy(name,s[1]->c_str(),128);
+	        name[127]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> start_time;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> last_block_time;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> last_block_done;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> missed;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> tape_quality;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> beam;
+	    }
+	      }
+
+	void tape::parse(const std::string &s) {
+	      SQL_ROW row(&s,8);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<settings>::table_name="settings";
+template <> const char * db_table<settings>::_search_tag=table_name;
+template <> const int db_table<settings>::_nfields=6;
+template <> const char * const db_table<settings>::column_names[6]={"id","active","recorder_cfg","splitter_cfg","analysis_cfg","receiver_cfg"};
+
+settings::settings() : 
+	db_table<settings>(*this,-1),
+	id(0),
+	active(0),
+	recorder_cfg(),
+	splitter_cfg(),
+	analysis_cfg(),
+	receiver_cfg()
+{
+	db_open();
+}
+
+
+settings::settings(const settings &a) : 
+	db_table<settings>(*this,-1),
+	id(a.id),
+	active(a.active),
+	recorder_cfg(a.recorder_cfg),
+	splitter_cfg(a.splitter_cfg),
+	analysis_cfg(a.analysis_cfg),
+	receiver_cfg(a.receiver_cfg)
+{
+	db_open();
+}
+
+
+settings::settings(const SQL_ROW &a) : 
+	db_table<settings>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+settings::settings(const std::string &s,const char *tag) : 
+	db_table<settings>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+settings &settings::operator =(const settings &a) {
+	if (&a != this) {
+		id=a.id;
+		active=a.active;
+		recorder_cfg=a.recorder_cfg;
+		splitter_cfg=a.splitter_cfg;
+		analysis_cfg=a.analysis_cfg;
+		receiver_cfg=a.receiver_cfg;
+	}
+	return (*this);
+}
+
+
+std::string settings::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<6;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string settings::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string settings::select_format() const
+{
+std::string rv("");
+for (int i=0; i<5;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string settings::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << active;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << recorder_cfg.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << recorder_cfg.id;
+	  }
+	}
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << splitter_cfg.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << splitter_cfg.id;
+	  }
+	}
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << analysis_cfg.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << analysis_cfg.id;
+	  }
+	}
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << receiver_cfg.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << receiver_cfg.id;
+	  }
+	}
+	return rv.str();
+}
+
+
+std::string settings::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<active>" << active << "</active>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << recorder_cfg.print_xml(full_subtables,show_ids,no_refs,"recorder_cfg");
+	} else {
+	    rv << xml_indent() << "<recorder_cfg><id>" << recorder_cfg.id << "</id></recorder_cfg>\n";
+	  }
+	}
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << splitter_cfg.print_xml(full_subtables,show_ids,no_refs,"splitter_cfg");
+	} else {
+	    rv << xml_indent() << "<splitter_cfg><id>" << splitter_cfg.id << "</id></splitter_cfg>\n";
+	  }
+	}
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << analysis_cfg.print_xml(full_subtables,show_ids,no_refs,"analysis_cfg");
+	} else {
+	    rv << xml_indent() << "<analysis_cfg><id>" << analysis_cfg.id << "</id></analysis_cfg>\n";
+	  }
+	}
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << receiver_cfg.print_xml(full_subtables,show_ids,no_refs,"receiver_cfg");
+	} else {
+	    rv << xml_indent() << "<receiver_cfg><id>" << receiver_cfg.id << "</id></receiver_cfg>\n";
+	  }
+	}
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void settings::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"active",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> active;
+	      }
+	    if (extract_xml_record(field,"recorder_cfg",sub)) {
+	      recorder_cfg.parse_xml(sub,"recorder_cfg");
+	    }
+	    if (extract_xml_record(field,"splitter_cfg",sub)) {
+	      splitter_cfg.parse_xml(sub,"splitter_cfg");
+	    }
+	    if (extract_xml_record(field,"analysis_cfg",sub)) {
+	      analysis_cfg.parse_xml(sub,"analysis_cfg");
+	    }
+	    if (extract_xml_record(field,"receiver_cfg",sub)) {
+	      receiver_cfg.parse_xml(sub,"receiver_cfg");
+	    }
+	      }
+	      }
+
+	void settings::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> active;
+	    }
+	  {  
+	  recorder_cfg.parse(SQL_ROW(s[2],0));
+	    }
+	  {  
+	  splitter_cfg.parse(SQL_ROW(s[3],0));
+	    }
+	  {  
+	  analysis_cfg.parse(SQL_ROW(s[4],0));
+	    }
+	  {  
+	  receiver_cfg.parse(SQL_ROW(s[5],0));
+	    }
+	      }
+
+	void settings::parse(const std::string &s) {
+	      SQL_ROW row(&s,6);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<workunit_grp>::table_name="workunit_grp";
+template <> const char * db_table<workunit_grp>::_search_tag=table_name;
+template <> const int db_table<workunit_grp>::_nfields=11;
+template <> const char * const db_table<workunit_grp>::column_names[11]={"id","tape_info","name","data_desc","receiver_cfg","recorder_cfg","splitter_cfg","analysis_cfg","sb_id","iq_modified","alfa_filter_bank"};
+
+workunit_grp::workunit_grp() : 
+	db_table<workunit_grp>(*this,-1),
+	id(0),
+	tape_info(),
+	data_desc(),
+	receiver_cfg(),
+	recorder_cfg(),
+	splitter_cfg(),
+	analysis_cfg(),
+	sb_id(0),
+	iq_modified(0),
+	alfa_filter_bank(0)
+{
+	db_open();
+	name[0]=0;
+}
+
+
+workunit_grp::workunit_grp(const workunit_grp &a) : 
+	db_table<workunit_grp>(*this,-1),
+	id(a.id),
+	tape_info(a.tape_info),
+	data_desc(a.data_desc),
+	receiver_cfg(a.receiver_cfg),
+	recorder_cfg(a.recorder_cfg),
+	splitter_cfg(a.splitter_cfg),
+	analysis_cfg(a.analysis_cfg),
+	sb_id(a.sb_id),
+	iq_modified(a.iq_modified),
+	alfa_filter_bank(a.alfa_filter_bank)
+{
+	db_open();
+	strcpy(name,a.name);
+}
+
+
+workunit_grp::workunit_grp(const SQL_ROW &a) : 
+	db_table<workunit_grp>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+workunit_grp::workunit_grp(const std::string &s,const char *tag) : 
+	db_table<workunit_grp>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+workunit_grp &workunit_grp::operator =(const workunit_grp &a) {
+	if (&a != this) {
+		id=a.id;
+		tape_info=a.tape_info;
+		data_desc=a.data_desc;
+		receiver_cfg=a.receiver_cfg;
+		recorder_cfg=a.recorder_cfg;
+		splitter_cfg=a.splitter_cfg;
+		analysis_cfg=a.analysis_cfg;
+		sb_id=a.sb_id;
+		iq_modified=a.iq_modified;
+		alfa_filter_bank=a.alfa_filter_bank;
+	strcpy(name,a.name);
+	}
+	return (*this);
+}
+
+
+std::string workunit_grp::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<11;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string workunit_grp::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string workunit_grp::select_format() const
+{
+std::string rv("");
+for (int i=0; i<10;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string workunit_grp::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << tape_info.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << tape_info.id;
+	  }
+	}
+	rv << ',';
+	rv << "'" << name << "'";
+	rv << ',';
+	rv << data_desc.print(full_subtables,show_ids,no_refs);
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << receiver_cfg.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << receiver_cfg.id;
+	  }
+	}
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << recorder_cfg.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << recorder_cfg.id;
+	  }
+	}
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << splitter_cfg.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << splitter_cfg.id;
+	  }
+	}
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << analysis_cfg.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << analysis_cfg.id;
+	  }
+	}
+	rv << ',';
+	rv << sb_id;
+	rv << ',';
+	rv << iq_modified;
+	rv << ',';
+	rv << alfa_filter_bank;
+	return rv.str();
+}
+
+
+std::string workunit_grp::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << tape_info.print_xml(full_subtables,show_ids,no_refs,"tape_info");
+	} else {
+	    rv << xml_indent() << "<tape_info><id>" << tape_info.id << "</id></tape_info>\n";
+	  }
+	}
+	{
+	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
+	  rv << xml_indent() << "<name>";
+	  rv << enc_field << "</name>\n";
+	}
+	rv << data_desc.print_xml(full_subtables,show_ids,no_refs,"data_desc");
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << receiver_cfg.print_xml(full_subtables,show_ids,no_refs,"receiver_cfg");
+	} else {
+	    rv << xml_indent() << "<receiver_cfg><id>" << receiver_cfg.id << "</id></receiver_cfg>\n";
+	  }
+	}
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << recorder_cfg.print_xml(full_subtables,show_ids,no_refs,"recorder_cfg");
+	} else {
+	    rv << xml_indent() << "<recorder_cfg><id>" << recorder_cfg.id << "</id></recorder_cfg>\n";
+	  }
+	}
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << splitter_cfg.print_xml(full_subtables,show_ids,no_refs,"splitter_cfg");
+	} else {
+	    rv << xml_indent() << "<splitter_cfg><id>" << splitter_cfg.id << "</id></splitter_cfg>\n";
+	  }
+	}
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << analysis_cfg.print_xml(full_subtables,show_ids,no_refs,"analysis_cfg");
+	} else {
+	    rv << xml_indent() << "<analysis_cfg><id>" << analysis_cfg.id << "</id></analysis_cfg>\n";
+	  }
+	}
+	rv << xml_indent() << "<sb_id>" << sb_id << "</sb_id>\n";
+	rv << xml_indent() << "<iq_modified>" << iq_modified << "</iq_modified>\n";
+	rv << xml_indent() << "<alfa_filter_bank>" << alfa_filter_bank << "</alfa_filter_bank>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void workunit_grp::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"tape_info",sub)) {
+	      tape_info.parse_xml(sub,"tape_info");
+	    }
+	    if (extract_xml_record(field,"name",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)128));
+	        name[std::min(in.size(),(size_t)127)]=0;
+	      }
+	    if (extract_xml_record(field,"data_desc",sub)) {
+	      data_desc.parse_xml(sub,"data_desc");
+	    }
+	    if (extract_xml_record(field,"receiver_cfg",sub)) {
+	      receiver_cfg.parse_xml(sub,"receiver_cfg");
+	    }
+	    if (extract_xml_record(field,"recorder_cfg",sub)) {
+	      recorder_cfg.parse_xml(sub,"recorder_cfg");
+	    }
+	    if (extract_xml_record(field,"splitter_cfg",sub)) {
+	      splitter_cfg.parse_xml(sub,"splitter_cfg");
+	    }
+	    if (extract_xml_record(field,"analysis_cfg",sub)) {
+	      analysis_cfg.parse_xml(sub,"analysis_cfg");
+	    }
+	    if (extract_xml_record(field,"sb_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> sb_id;
+	      }
+	    if (extract_xml_record(field,"iq_modified",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> iq_modified;
+	      }
+	    if (extract_xml_record(field,"alfa_filter_bank",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> alfa_filter_bank;
+	      }
+	      }
+	      }
+
+	void workunit_grp::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  tape_info.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        strncpy(name,s[2]->c_str(),128);
+	        name[127]=0;
+	    }
+	  {  
+	  data_desc.parse(SQL_ROW(s[3],0));
+	    }
+	  {  
+	  receiver_cfg.parse(SQL_ROW(s[4],0));
+	    }
+	  {  
+	  recorder_cfg.parse(SQL_ROW(s[5],0));
+	    }
+	  {  
+	  splitter_cfg.parse(SQL_ROW(s[6],0));
+	    }
+	  {  
+	  analysis_cfg.parse(SQL_ROW(s[7],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> sb_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> iq_modified;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> alfa_filter_bank;
+	    }
+	      }
+
+	void workunit_grp::parse(const std::string &s) {
+	      SQL_ROW row(&s,11);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<workunit_header>::table_name="workunit_header";
+template <> const char * db_table<workunit_header>::_search_tag=table_name;
+template <> const int db_table<workunit_header>::_nfields=5;
+template <> const char * const db_table<workunit_header>::column_names[5]={"id","name","group_info","subband_desc","sb_id"};
+
+workunit_header::workunit_header() : 
+	db_table<workunit_header>(*this,-1),
+	id(0),
+	group_info(),
+	subband_desc(),
+	sb_id(0)
+{
+	db_open();
+	name[0]=0;
+}
+
+
+workunit_header::workunit_header(const workunit_header &a) : 
+	db_table<workunit_header>(*this,-1),
+	id(a.id),
+	group_info(a.group_info),
+	subband_desc(a.subband_desc),
+	sb_id(a.sb_id)
+{
+	db_open();
+	strcpy(name,a.name);
+}
+
+
+workunit_header::workunit_header(const SQL_ROW &a) : 
+	db_table<workunit_header>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+workunit_header::workunit_header(const std::string &s,const char *tag) : 
+	db_table<workunit_header>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+workunit_header &workunit_header::operator =(const workunit_header &a) {
+	if (&a != this) {
+		id=a.id;
+		group_info=a.group_info;
+		subband_desc=a.subband_desc;
+		sb_id=a.sb_id;
+	strcpy(name,a.name);
+	}
+	return (*this);
+}
+
+
+std::string workunit_header::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<5;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string workunit_header::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string workunit_header::select_format() const
+{
+std::string rv("");
+for (int i=0; i<4;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string workunit_header::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << "'" << name << "'";
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << group_info.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << group_info.id;
+	  }
+	}
+	rv << ',';
+	rv << subband_desc.print(full_subtables,show_ids,no_refs);
+	rv << ',';
+	rv << sb_id;
+	return rv.str();
+}
+
+
+std::string workunit_header::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	{
+	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
+	  rv << xml_indent() << "<name>";
+	  rv << enc_field << "</name>\n";
+	}
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << group_info.print_xml(full_subtables,show_ids,no_refs,"group_info");
+	} else {
+	    rv << xml_indent() << "<group_info><id>" << group_info.id << "</id></group_info>\n";
+	  }
+	}
+	rv << subband_desc.print_xml(full_subtables,show_ids,no_refs,"subband_desc");
+	rv << xml_indent() << "<sb_id>" << sb_id << "</sb_id>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void workunit_header::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"name",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)128));
+	        name[std::min(in.size(),(size_t)127)]=0;
+	      }
+	    if (extract_xml_record(field,"group_info",sub)) {
+	      group_info.parse_xml(sub,"group_info");
+	    }
+	    if (extract_xml_record(field,"subband_desc",sub)) {
+	      subband_desc.parse_xml(sub,"subband_desc");
+	    }
+	    if (extract_xml_record(field,"sb_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> sb_id;
+	      }
+	      }
+	      }
+
+	void workunit_header::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        strncpy(name,s[1]->c_str(),128);
+	        name[127]=0;
+	    }
+	  {  
+	  group_info.parse(SQL_ROW(s[2],0));
+	    }
+	  {  
+	  subband_desc.parse(SQL_ROW(s[3],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> sb_id;
+	    }
+	      }
+
+	void workunit_header::parse(const std::string &s) {
+	      SQL_ROW row(&s,5);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<result>::table_name="result";
+template <> const char * db_table<result>::_search_tag=table_name;
+template <> const int db_table<result>::_nfields=10;
+template <> const char * const db_table<result>::column_names[10]={"id","boinc_result","wuid","received","hostid","versionid","return_code","overflow","reserved","sb_id"};
+
+result::result() : 
+	db_table<result>(*this,-1),
+	id(0),
+	boinc_result(0),
+	wuid(),
+	received(0),
+	hostid(0),
+	versionid(0),
+	return_code(0),
+	overflow(0),
+	reserved(0),
+	sb_id(0)
+{
+	db_open();
+}
+
+
+result::result(const result &a) : 
+	db_table<result>(*this,-1),
+	id(a.id),
+	boinc_result(a.boinc_result),
+	wuid(a.wuid),
+	received(a.received),
+	hostid(a.hostid),
+	versionid(a.versionid),
+	return_code(a.return_code),
+	overflow(a.overflow),
+	reserved(a.reserved),
+	sb_id(a.sb_id)
+{
+	db_open();
+}
+
+
+result::result(const SQL_ROW &a) : 
+	db_table<result>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+result::result(const std::string &s,const char *tag) : 
+	db_table<result>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+result &result::operator =(const result &a) {
+	if (&a != this) {
+		id=a.id;
+		boinc_result=a.boinc_result;
+		wuid=a.wuid;
+		received=a.received;
+		hostid=a.hostid;
+		versionid=a.versionid;
+		return_code=a.return_code;
+		overflow=a.overflow;
+		reserved=a.reserved;
+		sb_id=a.sb_id;
+	}
+	return (*this);
+}
+
+
+std::string result::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<10;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string result::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string result::select_format() const
+{
+std::string rv("");
+for (int i=0; i<9;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string result::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << boinc_result;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << wuid.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << wuid.id;
+	  }
+	}
+	rv << ',';
+	rv << received;
+	rv << ',';
+	rv << hostid;
+	rv << ',';
+	rv << versionid;
+	rv << ',';
+	rv << return_code;
+	rv << ',';
+	rv << overflow;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << sb_id;
+	return rv.str();
+}
+
+
+std::string result::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<boinc_result>" << boinc_result << "</boinc_result>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << wuid.print_xml(full_subtables,show_ids,no_refs,"wuid");
+	} else {
+	    rv << xml_indent() << "<wuid><id>" << wuid.id << "</id></wuid>\n";
+	  }
+	}
+	rv << xml_indent() << "<received>" << received << "</received>\n";
+	rv << xml_indent() << "<hostid>" << hostid << "</hostid>\n";
+	rv << xml_indent() << "<versionid>" << versionid << "</versionid>\n";
+	rv << xml_indent() << "<return_code>" << return_code << "</return_code>\n";
+	rv << xml_indent() << "<overflow>" << overflow << "</overflow>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<sb_id>" << sb_id << "</sb_id>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void result::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"boinc_result",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> boinc_result;
+	      }
+	    if (extract_xml_record(field,"wuid",sub)) {
+	      wuid.parse_xml(sub,"wuid");
+	    }
+	    if (extract_xml_record(field,"received",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> received;
+	      }
+	    if (extract_xml_record(field,"hostid",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> hostid;
+	      }
+	    if (extract_xml_record(field,"versionid",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> versionid;
+	      }
+	    if (extract_xml_record(field,"return_code",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> return_code;
+	      }
+	    if (extract_xml_record(field,"overflow",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> overflow;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"sb_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> sb_id;
+	      }
+	      }
+	      }
+
+	void result::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> boinc_result;
+	    }
+	  {  
+	  wuid.parse(SQL_ROW(s[2],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> received;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> hostid;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> versionid;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> return_code;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> overflow;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> sb_id;
+	    }
+	      }
+
+	void result::parse(const std::string &s) {
+	      SQL_ROW row(&s,10);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<triplet>::table_name="triplet";
+template <> const char * db_table<triplet>::_search_tag=table_name;
+template <> const int db_table<triplet>::_nfields=17;
+template <> const char * const db_table<triplet>::column_names[17]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period"};
+
+triplet::triplet() : 
+	db_table<triplet>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0),
+	period(0)
+{
+	db_open();
+}
+
+
+triplet::triplet(const triplet &a) : 
+	db_table<triplet>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved),
+	period(a.period)
+{
+	db_open();
+}
+
+
+triplet::triplet(const SQL_ROW &a) : 
+	db_table<triplet>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+triplet::triplet(const std::string &s,const char *tag) : 
+	db_table<triplet>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+triplet &triplet::operator =(const triplet &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+		period=a.period;
+	}
+	return (*this);
+}
+
+
+std::string triplet::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<17;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string triplet::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string triplet::select_format() const
+{
+std::string rv("");
+for (int i=0; i<16;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string triplet::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << period;
+	return rv.str();
+}
+
+
+std::string triplet::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<period>" << period << "</period>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void triplet::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"period",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> period;
+	      }
+	      }
+	      }
+
+	void triplet::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> period;
+	    }
+	      }
+
+	void triplet::parse(const std::string &s) {
+	      SQL_ROW row(&s,17);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<triplet_small>::table_name="triplet_small";
+template <> const char * db_table<triplet_small>::_search_tag=table_name;
+template <> const int db_table<triplet_small>::_nfields=17;
+template <> const char * const db_table<triplet_small>::column_names[17]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period"};
+
+triplet_small::triplet_small() : 
+	db_table<triplet_small>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0),
+	period(0)
+{
+	db_open();
+}
+
+
+triplet_small::triplet_small(const triplet_small &a) : 
+	db_table<triplet_small>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved),
+	period(a.period)
+{
+	db_open();
+}
+
+
+triplet_small::triplet_small(const SQL_ROW &a) : 
+	db_table<triplet_small>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+triplet_small::triplet_small(const std::string &s,const char *tag) : 
+	db_table<triplet_small>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+triplet_small &triplet_small::operator =(const triplet_small &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+		period=a.period;
+	}
+	return (*this);
+}
+
+
+std::string triplet_small::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<17;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string triplet_small::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string triplet_small::select_format() const
+{
+std::string rv("");
+for (int i=0; i<16;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string triplet_small::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << period;
+	return rv.str();
+}
+
+
+std::string triplet_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<period>" << period << "</period>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void triplet_small::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"period",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> period;
+	      }
+	      }
+	      }
+
+	void triplet_small::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> period;
+	    }
+	      }
+
+	void triplet_small::parse(const std::string &s) {
+	      SQL_ROW row(&s,17);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<gaussian>::table_name="gaussian";
+template <> const char * db_table<gaussian>::_search_tag=table_name;
+template <> const int db_table<gaussian>::_nfields=22;
+template <> const char * const db_table<gaussian>::column_names[22]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","sigma","chisqr","null_chisqr","score","max_power","pot"};
+
+gaussian::gaussian() : 
+	db_table<gaussian>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0),
+	sigma(0),
+	chisqr(0),
+	null_chisqr(0),
+	score(0),
+	max_power(0),
+	pot((unsigned char *)0,0,_x_csv)
+{
+	db_open();
+}
+
+
+gaussian::gaussian(const gaussian &a) : 
+	db_table<gaussian>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved),
+	sigma(a.sigma),
+	chisqr(a.chisqr),
+	null_chisqr(a.null_chisqr),
+	score(a.score),
+	max_power(a.max_power),
+	pot(a.pot)
+{
+	db_open();
 }
 
+
+gaussian::gaussian(const SQL_ROW &a) : 
+	db_table<gaussian>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+gaussian::gaussian(const std::string &s,const char *tag) : 
+	db_table<gaussian>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+gaussian &gaussian::operator =(const gaussian &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+		sigma=a.sigma;
+		chisqr=a.chisqr;
+		null_chisqr=a.null_chisqr;
+		score=a.score;
+		max_power=a.max_power;
+		pot=a.pot;
+	}
+	return (*this);
+}
+
+
+std::string gaussian::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<22;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string gaussian::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string gaussian::select_format() const
+{
+std::string rv("");
+for (int i=0; i<21;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string gaussian::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << sigma;
+	rv << ',';
+	rv << chisqr;
+	rv << ',';
+	rv << null_chisqr;
+	rv << ',';
+	rv << score;
+	rv << ',';
+	rv << max_power;
+	rv << ',';
+	rv << "<BYTE len=" << std::max(pot.size()*2,(size_t)1) << ">" << pot.print_hex() ;
+	return rv.str();
+}
+
+
+std::string gaussian::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<sigma>" << sigma << "</sigma>\n";
+	rv << xml_indent() << "<chisqr>" << chisqr << "</chisqr>\n";
+	rv << xml_indent() << "<null_chisqr>" << null_chisqr << "</null_chisqr>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	rv << xml_indent() << "<max_power>" << max_power << "</max_power>\n";
+	if (pot.size()) {
+	  std::string enc_field=xml_encode_string(pot,pot.encoding);
+	  rv << xml_indent() << "<pot length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[pot.encoding] << "\">"; 
+	  rv << enc_field << "</pot>\n";
+	}
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void gaussian::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"sigma",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> sigma;
+	      }
+	    if (extract_xml_record(field,"chisqr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chisqr;
+	      }
+	    if (extract_xml_record(field,"null_chisqr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> null_chisqr;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	    if (extract_xml_record(field,"max_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_power;
+	      }
+	    if (extract_xml_record(field,"pot",sub)) {
+	        std::istringstream in(sub.c_str());
+	        in >> pot;
+	      }
+	      }
+	      }
+
+	void gaussian::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> sigma;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> chisqr;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> null_chisqr;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> score;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> max_power;
+	    }
+	  {  
+	        pot=sqlblob<unsigned char>(*(s[21]));
+	    }
+	      }
+
+	void gaussian::parse(const std::string &s) {
+	      SQL_ROW row(&s,22);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<gaussian_small>::table_name="gaussian_small";
 template <> const char * db_table<gaussian_small>::_search_tag=table_name;
 template <> const int db_table<gaussian_small>::_nfields=21;
-template <> const char * const db_table<gaussian_small>::column_names[21]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","sigma","chisqr","null_chisqr","score","max_power"};
-
-gaussian_small::gaussian_small() :
-    db_table<gaussian_small>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0),
-    sigma(0),
-    chisqr(0),
-    null_chisqr(0),
-    score(0),
-    max_power(0) {
-    db_open();
-}
-
-
-gaussian_small::gaussian_small(const gaussian_small &a) :
-    db_table<gaussian_small>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved),
-    sigma(a.sigma),
-    chisqr(a.chisqr),
-    null_chisqr(a.null_chisqr),
-    score(a.score),
-    max_power(a.max_power) {
-    db_open();
-}
-
-
-gaussian_small::gaussian_small(const SQL_ROW &a) :
-    db_table<gaussian_small>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-gaussian_small::gaussian_small(const std::string &s,const char *tag) :
-    db_table<gaussian_small>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+template <> const char * const db_table<gaussian_small>::column_names[21]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","sigma","chisqr","null_chisqr","score","max_power"};
+
+gaussian_small::gaussian_small() : 
+	db_table<gaussian_small>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0),
+	sigma(0),
+	chisqr(0),
+	null_chisqr(0),
+	score(0),
+	max_power(0)
+{
+	db_open();
+}
+
+
+gaussian_small::gaussian_small(const gaussian_small &a) : 
+	db_table<gaussian_small>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved),
+	sigma(a.sigma),
+	chisqr(a.chisqr),
+	null_chisqr(a.null_chisqr),
+	score(a.score),
+	max_power(a.max_power)
+{
+	db_open();
+}
+
+
+gaussian_small::gaussian_small(const SQL_ROW &a) : 
+	db_table<gaussian_small>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+gaussian_small::gaussian_small(const std::string &s,const char *tag) : 
+	db_table<gaussian_small>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+gaussian_small &gaussian_small::operator =(const gaussian_small &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+		sigma=a.sigma;
+		chisqr=a.chisqr;
+		null_chisqr=a.null_chisqr;
+		score=a.score;
+		max_power=a.max_power;
+	}
+	return (*this);
+}
+
+
+std::string gaussian_small::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<21;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string gaussian_small::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string gaussian_small::select_format() const
+{
+std::string rv("");
+for (int i=0; i<20;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string gaussian_small::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << sigma;
+	rv << ',';
+	rv << chisqr;
+	rv << ',';
+	rv << null_chisqr;
+	rv << ',';
+	rv << score;
+	rv << ',';
+	rv << max_power;
+	return rv.str();
+}
+
+
+std::string gaussian_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<sigma>" << sigma << "</sigma>\n";
+	rv << xml_indent() << "<chisqr>" << chisqr << "</chisqr>\n";
+	rv << xml_indent() << "<null_chisqr>" << null_chisqr << "</null_chisqr>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	rv << xml_indent() << "<max_power>" << max_power << "</max_power>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void gaussian_small::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"sigma",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> sigma;
+	      }
+	    if (extract_xml_record(field,"chisqr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chisqr;
+	      }
+	    if (extract_xml_record(field,"null_chisqr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> null_chisqr;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	    if (extract_xml_record(field,"max_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_power;
+	      }
+	      }
+	      }
+
+	void gaussian_small::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> sigma;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> chisqr;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> null_chisqr;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> score;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> max_power;
+	    }
+	      }
+
+	void gaussian_small::parse(const std::string &s) {
+	      SQL_ROW row(&s,21);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<pulse>::table_name="pulse";
+template <> const char * db_table<pulse>::_search_tag=table_name;
+template <> const int db_table<pulse>::_nfields=22;
+template <> const char * const db_table<pulse>::column_names[22]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period","snr","thresh","score","len_prof","pot"};
+
+pulse::pulse() : 
+	db_table<pulse>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0),
+	period(0),
+	snr(0),
+	thresh(0),
+	score(0),
+	len_prof(0),
+	pot((unsigned char *)0,0,_x_csv)
+{
+	db_open();
+}
+
+
+pulse::pulse(const pulse &a) : 
+	db_table<pulse>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved),
+	period(a.period),
+	snr(a.snr),
+	thresh(a.thresh),
+	score(a.score),
+	len_prof(a.len_prof),
+	pot(a.pot)
+{
+	db_open();
+}
+
+
+pulse::pulse(const SQL_ROW &a) : 
+	db_table<pulse>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+pulse::pulse(const std::string &s,const char *tag) : 
+	db_table<pulse>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+pulse &pulse::operator =(const pulse &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+		period=a.period;
+		snr=a.snr;
+		thresh=a.thresh;
+		score=a.score;
+		len_prof=a.len_prof;
+		pot=a.pot;
+	}
+	return (*this);
+}
+
+
+std::string pulse::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<22;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string pulse::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string pulse::select_format() const
+{
+std::string rv("");
+for (int i=0; i<21;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string pulse::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << period;
+	rv << ',';
+	rv << snr;
+	rv << ',';
+	rv << thresh;
+	rv << ',';
+	rv << score;
+	rv << ',';
+	rv << len_prof;
+	rv << ',';
+	rv << "<BYTE len=" << std::max(pot.size()*2,(size_t)1) << ">" << pot.print_hex() ;
+	return rv.str();
+}
+
+
+std::string pulse::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<period>" << period << "</period>\n";
+	rv << xml_indent() << "<snr>" << snr << "</snr>\n";
+	rv << xml_indent() << "<thresh>" << thresh << "</thresh>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	rv << xml_indent() << "<len_prof>" << len_prof << "</len_prof>\n";
+	if (pot.size()) {
+	  std::string enc_field=xml_encode_string(pot,pot.encoding);
+	  rv << xml_indent() << "<pot length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[pot.encoding] << "\">"; 
+	  rv << enc_field << "</pot>\n";
+	}
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void pulse::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"period",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> period;
+	      }
+	    if (extract_xml_record(field,"snr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> snr;
+	      }
+	    if (extract_xml_record(field,"thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> thresh;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	    if (extract_xml_record(field,"len_prof",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> len_prof;
+	      }
+	    if (extract_xml_record(field,"pot",sub)) {
+	        std::istringstream in(sub.c_str());
+	        in >> pot;
+	      }
+	      }
+	      }
+
+	void pulse::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> period;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> snr;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> score;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> len_prof;
+	    }
+	  {  
+	        pot=sqlblob<unsigned char>(*(s[21]));
+	    }
+	      }
+
+	void pulse::parse(const std::string &s) {
+	      SQL_ROW row(&s,22);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<pulse_small>::table_name="pulse_small";
+template <> const char * db_table<pulse_small>::_search_tag=table_name;
+template <> const int db_table<pulse_small>::_nfields=20;
+template <> const char * const db_table<pulse_small>::column_names[20]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period","snr","thresh","score"};
+
+pulse_small::pulse_small() : 
+	db_table<pulse_small>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0),
+	period(0),
+	snr(0),
+	thresh(0),
+	score(0)
+{
+	db_open();
+}
+
+
+pulse_small::pulse_small(const pulse_small &a) : 
+	db_table<pulse_small>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved),
+	period(a.period),
+	snr(a.snr),
+	thresh(a.thresh),
+	score(a.score)
+{
+	db_open();
+}
+
+
+pulse_small::pulse_small(const SQL_ROW &a) : 
+	db_table<pulse_small>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+pulse_small::pulse_small(const std::string &s,const char *tag) : 
+	db_table<pulse_small>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+pulse_small &pulse_small::operator =(const pulse_small &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+		period=a.period;
+		snr=a.snr;
+		thresh=a.thresh;
+		score=a.score;
+	}
+	return (*this);
+}
+
+
+std::string pulse_small::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<20;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string pulse_small::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string pulse_small::select_format() const
+{
+std::string rv("");
+for (int i=0; i<19;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string pulse_small::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << period;
+	rv << ',';
+	rv << snr;
+	rv << ',';
+	rv << thresh;
+	rv << ',';
+	rv << score;
+	return rv.str();
+}
+
+
+std::string pulse_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<period>" << period << "</period>\n";
+	rv << xml_indent() << "<snr>" << snr << "</snr>\n";
+	rv << xml_indent() << "<thresh>" << thresh << "</thresh>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void pulse_small::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"period",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> period;
+	      }
+	    if (extract_xml_record(field,"snr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> snr;
+	      }
+	    if (extract_xml_record(field,"thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> thresh;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	      }
+	      }
+
+	void pulse_small::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> period;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> snr;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> score;
+	    }
+	      }
+
+	void pulse_small::parse(const std::string &s) {
+	      SQL_ROW row(&s,20);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<sah_pointing>::table_name="sah_pointing";
+template <> const char * db_table<sah_pointing>::_search_tag=table_name;
+template <> const int db_table<sah_pointing>::_nfields=7;
+template <> const char * const db_table<sah_pointing>::column_names[7]={"time_id","time","ra","dec","q_pix","angle_range","bad"};
+
+sah_pointing::sah_pointing() : 
+	db_table<sah_pointing>(*this,-1),
+	time_id(0),
+	time(0),
+	ra(0),
+	dec(0),
+	q_pix(0),
+	angle_range(0),
+	bad(0)
+{
+	db_open();
+}
+
+
+sah_pointing::sah_pointing(const sah_pointing &a) : 
+	db_table<sah_pointing>(*this,-1),
+	time_id(a.time_id),
+	time(a.time),
+	ra(a.ra),
+	dec(a.dec),
+	q_pix(a.q_pix),
+	angle_range(a.angle_range),
+	bad(a.bad)
+{
+	db_open();
+}
+
+
+sah_pointing::sah_pointing(const SQL_ROW &a) : 
+	db_table<sah_pointing>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+sah_pointing::sah_pointing(const std::string &s,const char *tag) : 
+	db_table<sah_pointing>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+sah_pointing &sah_pointing::operator =(const sah_pointing &a) {
+	if (&a != this) {
+		time_id=a.time_id;
+		time=a.time;
+		ra=a.ra;
+		dec=a.dec;
+		q_pix=a.q_pix;
+		angle_range=a.angle_range;
+		bad=a.bad;
+	}
+	return (*this);
+}
+
+
+std::string sah_pointing::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<7;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string sah_pointing::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string sah_pointing::select_format() const
+{
+std::string rv("");
+for (int i=0; i<6;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string sah_pointing::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << time_id;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << dec;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << angle_range;
+	rv << ',';
+	rv << bad;
+	return rv.str();
+}
+
+
+std::string sah_pointing::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<time_id>" << time_id << "</time_id>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<dec>" << dec << "</dec>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<angle_range>" << angle_range << "</angle_range>\n";
+	rv << xml_indent() << "<bad>" << bad << "</bad>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void sah_pointing::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"time_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time_id;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"dec",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> dec;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"angle_range",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> angle_range;
+	      }
+	    if (extract_xml_record(field,"bad",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> bad;
+	      }
+	      }
+	      }
+
+	void sah_pointing::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> time_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> dec;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> angle_range;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> bad;
+	    }
+	      }
+
+	void sah_pointing::parse(const std::string &s) {
+	      SQL_ROW row(&s,7);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<sky_map>::table_name="sky_map";
+template <> const char * db_table<sky_map>::_search_tag=table_name;
+template <> const int db_table<sky_map>::_nfields=13;
+template <> const char * const db_table<sky_map>::column_names[13]={"npix","qpix","fpix","spike_max_id","gaussian_max_id","pulse_max_id","triplet_max_id","spike_count","gaussian_count","pulse_count","triplet_count","new_data","score"};
+
+sky_map::sky_map() : 
+	db_table<sky_map>(*this,-1),
+	npix(0),
+	qpix(0),
+	fpix(0),
+	spike_max_id(0),
+	gaussian_max_id(0),
+	pulse_max_id(0),
+	triplet_max_id(0),
+	spike_count(0),
+	gaussian_count(0),
+	pulse_count(0),
+	triplet_count(0),
+	new_data(0),
+	score(0)
+{
+	db_open();
+}
+
+
+sky_map::sky_map(const sky_map &a) : 
+	db_table<sky_map>(*this,-1),
+	npix(a.npix),
+	qpix(a.qpix),
+	fpix(a.fpix),
+	spike_max_id(a.spike_max_id),
+	gaussian_max_id(a.gaussian_max_id),
+	pulse_max_id(a.pulse_max_id),
+	triplet_max_id(a.triplet_max_id),
+	spike_count(a.spike_count),
+	gaussian_count(a.gaussian_count),
+	pulse_count(a.pulse_count),
+	triplet_count(a.triplet_count),
+	new_data(a.new_data),
+	score(a.score)
+{
+	db_open();
+}
+
+
+sky_map::sky_map(const SQL_ROW &a) : 
+	db_table<sky_map>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+sky_map::sky_map(const std::string &s,const char *tag) : 
+	db_table<sky_map>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+sky_map &sky_map::operator =(const sky_map &a) {
+	if (&a != this) {
+		npix=a.npix;
+		qpix=a.qpix;
+		fpix=a.fpix;
+		spike_max_id=a.spike_max_id;
+		gaussian_max_id=a.gaussian_max_id;
+		pulse_max_id=a.pulse_max_id;
+		triplet_max_id=a.triplet_max_id;
+		spike_count=a.spike_count;
+		gaussian_count=a.gaussian_count;
+		pulse_count=a.pulse_count;
+		triplet_count=a.triplet_count;
+		new_data=a.new_data;
+		score=a.score;
+	}
+	return (*this);
+}
+
+
+std::string sky_map::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<13;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string sky_map::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string sky_map::select_format() const
+{
+std::string rv("");
+for (int i=0; i<12;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string sky_map::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << npix;
+	rv << ',';
+	rv << qpix;
+	rv << ',';
+	rv << fpix;
+	rv << ',';
+	rv << spike_max_id;
+	rv << ',';
+	rv << gaussian_max_id;
+	rv << ',';
+	rv << pulse_max_id;
+	rv << ',';
+	rv << triplet_max_id;
+	rv << ',';
+	rv << spike_count;
+	rv << ',';
+	rv << gaussian_count;
+	rv << ',';
+	rv << pulse_count;
+	rv << ',';
+	rv << triplet_count;
+	rv << ',';
+	rv << new_data;
+	rv << ',';
+	rv << score;
+	return rv.str();
+}
+
+
+std::string sky_map::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<npix>" << npix << "</npix>\n";
+	rv << xml_indent() << "<qpix>" << qpix << "</qpix>\n";
+	rv << xml_indent() << "<fpix>" << fpix << "</fpix>\n";
+	rv << xml_indent() << "<spike_max_id>" << spike_max_id << "</spike_max_id>\n";
+	rv << xml_indent() << "<gaussian_max_id>" << gaussian_max_id << "</gaussian_max_id>\n";
+	rv << xml_indent() << "<pulse_max_id>" << pulse_max_id << "</pulse_max_id>\n";
+	rv << xml_indent() << "<triplet_max_id>" << triplet_max_id << "</triplet_max_id>\n";
+	rv << xml_indent() << "<spike_count>" << spike_count << "</spike_count>\n";
+	rv << xml_indent() << "<gaussian_count>" << gaussian_count << "</gaussian_count>\n";
+	rv << xml_indent() << "<pulse_count>" << pulse_count << "</pulse_count>\n";
+	rv << xml_indent() << "<triplet_count>" << triplet_count << "</triplet_count>\n";
+	rv << xml_indent() << "<new_data>" << new_data << "</new_data>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void sky_map::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"npix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> npix;
+	      }
+	    if (extract_xml_record(field,"qpix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> qpix;
+	      }
+	    if (extract_xml_record(field,"fpix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fpix;
+	      }
+	    if (extract_xml_record(field,"spike_max_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spike_max_id;
+	      }
+	    if (extract_xml_record(field,"gaussian_max_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gaussian_max_id;
+	      }
+	    if (extract_xml_record(field,"pulse_max_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_max_id;
+	      }
+	    if (extract_xml_record(field,"triplet_max_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_max_id;
+	      }
+	    if (extract_xml_record(field,"spike_count",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> spike_count;
+	      }
+	    if (extract_xml_record(field,"gaussian_count",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> gaussian_count;
+	      }
+	    if (extract_xml_record(field,"pulse_count",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> pulse_count;
+	      }
+	    if (extract_xml_record(field,"triplet_count",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> triplet_count;
+	      }
+	    if (extract_xml_record(field,"new_data",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> new_data;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	      }
+	      }
+
+	void sky_map::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> npix;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> qpix;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> fpix;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> spike_max_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> gaussian_max_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> pulse_max_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> triplet_max_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> spike_count;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> gaussian_count;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> pulse_count;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> triplet_count;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> new_data;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> score;
+	    }
+	      }
+
+	void sky_map::parse(const std::string &s) {
+	      SQL_ROW row(&s,13);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<hotpix>::table_name="hotpix";
+template <> const char * db_table<hotpix>::_search_tag=table_name;
+template <> const int db_table<hotpix>::_nfields=2;
+template <> const char * const db_table<hotpix>::column_names[2]={"id","last_hit_time"};
+
+hotpix::hotpix() : 
+	db_table<hotpix>(*this,-1),
+	id(0),
+	last_hit_time(0)
+{
+	db_open();
+}
+
+
+hotpix::hotpix(const hotpix &a) : 
+	db_table<hotpix>(*this,-1),
+	id(a.id),
+	last_hit_time(a.last_hit_time)
+{
+	db_open();
+}
+
+
+hotpix::hotpix(const SQL_ROW &a) : 
+	db_table<hotpix>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+hotpix::hotpix(const std::string &s,const char *tag) : 
+	db_table<hotpix>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
+}
+
+
+hotpix &hotpix::operator =(const hotpix &a) {
+	if (&a != this) {
+		id=a.id;
+		last_hit_time=a.last_hit_time;
+	}
+	return (*this);
+}
+
+
+std::string hotpix::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<2;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string hotpix::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string hotpix::select_format() const
+{
+std::string rv("");
+for (int i=0; i<1;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string hotpix::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << last_hit_time;
+	return rv.str();
+}
+
+
+std::string hotpix::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<last_hit_time>" << last_hit_time << "</last_hit_time>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void hotpix::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"last_hit_time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> last_hit_time;
+	      }
+	      }
+	      }
+
+	void hotpix::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> last_hit_time;
+	    }
+	      }
+
+	void hotpix::parse(const std::string &s) {
+	      SQL_ROW row(&s,2);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<hotpix_tinysky>::table_name="hotpix_tinysky";
+template <> const char * db_table<hotpix_tinysky>::_search_tag=table_name;
+template <> const int db_table<hotpix_tinysky>::_nfields=2;
+template <> const char * const db_table<hotpix_tinysky>::column_names[2]={"id","last_hit_time"};
+
+hotpix_tinysky::hotpix_tinysky() : 
+	db_table<hotpix_tinysky>(*this,-1),
+	id(0),
+	last_hit_time(0)
+{
+	db_open();
+}
+
+
+hotpix_tinysky::hotpix_tinysky(const hotpix_tinysky &a) : 
+	db_table<hotpix_tinysky>(*this,-1),
+	id(a.id),
+	last_hit_time(a.last_hit_time)
+{
+	db_open();
+}
+
+
+hotpix_tinysky::hotpix_tinysky(const SQL_ROW &a) : 
+	db_table<hotpix_tinysky>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-gaussian_small &gaussian_small::operator =(const gaussian_small &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-        sigma=a.sigma;
-        chisqr=a.chisqr;
-        null_chisqr=a.null_chisqr;
-        score=a.score;
-        max_power=a.max_power;
-    }
-    return (*this);
-}
-
-
-std::string gaussian_small::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<21; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string gaussian_small::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string gaussian_small::select_format() const {
-    std::string rv("");
-    for (int i=0; i<20; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string gaussian_small::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << sigma;
-    rv << ',';
-    rv << chisqr;
-    rv << ',';
-    rv << null_chisqr;
-    rv << ',';
-    rv << score;
-    rv << ',';
-    rv << max_power;
-    return rv.str();
-}
-
-
-std::string gaussian_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<sigma>" << sigma << "</sigma>\n";
-    rv << xml_indent() << "<chisqr>" << chisqr << "</chisqr>\n";
-    rv << xml_indent() << "<null_chisqr>" << null_chisqr << "</null_chisqr>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    rv << xml_indent() << "<max_power>" << max_power << "</max_power>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void gaussian_small::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"sigma",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> sigma;
-        }
-        if (extract_xml_record(field,"chisqr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chisqr;
-        }
-        if (extract_xml_record(field,"null_chisqr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> null_chisqr;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-        if (extract_xml_record(field,"max_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_power;
-        }
-    }
-}
-
-void gaussian_small::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> sigma;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> chisqr;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> null_chisqr;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> score;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> max_power;
-    }
-}
-
-void gaussian_small::parse(const std::string &s) {
-    SQL_ROW row(&s,21);
-    parse(row);
+hotpix_tinysky::hotpix_tinysky(const std::string &s,const char *tag) : 
+	db_table<hotpix_tinysky>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
-template <> const char * const db_table<pulse>::table_name="pulse";
-template <> const char * db_table<pulse>::_search_tag=table_name;
-template <> const int db_table<pulse>::_nfields=22;
-template <> const char * const db_table<pulse>::column_names[22]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period","snr","thresh","score","len_prof","pot"};
-
-pulse::pulse() :
-    db_table<pulse>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0),
-    period(0),
-    snr(0),
-    thresh(0),
-    score(0),
-    len_prof(0),
-    pot((unsigned char *)0,0,_x_csv) {
-    db_open();
-}
-
-
-pulse::pulse(const pulse &a) :
-    db_table<pulse>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved),
-    period(a.period),
-    snr(a.snr),
-    thresh(a.thresh),
-    score(a.score),
-    len_prof(a.len_prof),
-    pot(a.pot) {
-    db_open();
-}
-
-
-pulse::pulse(const SQL_ROW &a) :
-    db_table<pulse>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-pulse::pulse(const std::string &s,const char *tag) :
-    db_table<pulse>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+
+hotpix_tinysky &hotpix_tinysky::operator =(const hotpix_tinysky &a) {
+	if (&a != this) {
+		id=a.id;
+		last_hit_time=a.last_hit_time;
+	}
+	return (*this);
 }
 
 
-pulse &pulse::operator =(const pulse &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-        period=a.period;
-        snr=a.snr;
-        thresh=a.thresh;
-        score=a.score;
-        len_prof=a.len_prof;
-        pot=a.pot;
-    }
-    return (*this);
-}
-
-
-std::string pulse::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<22; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string pulse::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string pulse::select_format() const {
-    std::string rv("");
-    for (int i=0; i<21; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string pulse::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << period;
-    rv << ',';
-    rv << snr;
-    rv << ',';
-    rv << thresh;
-    rv << ',';
-    rv << score;
-    rv << ',';
-    rv << len_prof;
-    rv << ',';
-    rv << "<BYTE len=" << std::max(pot.size()*2,(size_t)1) << ">" << pot.print_hex() ;
-    return rv.str();
-}
-
-
-std::string pulse::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<period>" << period << "</period>\n";
-    rv << xml_indent() << "<snr>" << snr << "</snr>\n";
-    rv << xml_indent() << "<thresh>" << thresh << "</thresh>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    rv << xml_indent() << "<len_prof>" << len_prof << "</len_prof>\n";
-    if (pot.size()) {
-        std::string enc_field=xml_encode_string(pot,pot.encoding);
-        rv << xml_indent() << "<pot length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[pot.encoding] << "\">";
-        rv << enc_field << "</pot>\n";
-    }
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void pulse::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"period",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> period;
-        }
-        if (extract_xml_record(field,"snr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> snr;
-        }
-        if (extract_xml_record(field,"thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> thresh;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-        if (extract_xml_record(field,"len_prof",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> len_prof;
-        }
-        if (extract_xml_record(field,"pot",sub)) {
-            std::istringstream in(sub.c_str());
-            in >> pot;
-        }
-    }
-}
-
-void pulse::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> period;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> snr;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> thresh;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> score;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> len_prof;
-    }
-    {
-        pot=sqlblob<unsigned char>(*(s[21]));
-    }
-}
-
-void pulse::parse(const std::string &s) {
-    SQL_ROW row(&s,22);
-    parse(row);
-}
+std::string hotpix_tinysky::update_format() const
+{	std::ostringstream rv("");
 
-template <> const char * const db_table<pulse_small>::table_name="pulse_small";
-template <> const char * db_table<pulse_small>::_search_tag=table_name;
-template <> const int db_table<pulse_small>::_nfields=20;
-template <> const char * const db_table<pulse_small>::column_names[20]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period","snr","thresh","score"};
-
-pulse_small::pulse_small() :
-    db_table<pulse_small>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0),
-    period(0),
-    snr(0),
-    thresh(0),
-    score(0) {
-    db_open();
-}
-
-
-pulse_small::pulse_small(const pulse_small &a) :
-    db_table<pulse_small>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved),
-    period(a.period),
-    snr(a.snr),
-    thresh(a.thresh),
-    score(a.score) {
-    db_open();
-}
-
-
-pulse_small::pulse_small(const SQL_ROW &a) :
-    db_table<pulse_small>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-pulse_small::pulse_small(const std::string &s,const char *tag) :
-    db_table<pulse_small>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+	for (int i=2;i<2;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-pulse_small &pulse_small::operator =(const pulse_small &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-        period=a.period;
-        snr=a.snr;
-        thresh=a.thresh;
-        score=a.score;
-    }
-    return (*this);
-}
-
-
-std::string pulse_small::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<20; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string pulse_small::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string pulse_small::select_format() const {
-    std::string rv("");
-    for (int i=0; i<19; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string pulse_small::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << period;
-    rv << ',';
-    rv << snr;
-    rv << ',';
-    rv << thresh;
-    rv << ',';
-    rv << score;
-    return rv.str();
-}
-
-
-std::string pulse_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<period>" << period << "</period>\n";
-    rv << xml_indent() << "<snr>" << snr << "</snr>\n";
-    rv << xml_indent() << "<thresh>" << thresh << "</thresh>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void pulse_small::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"period",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> period;
-        }
-        if (extract_xml_record(field,"snr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> snr;
-        }
-        if (extract_xml_record(field,"thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> thresh;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-    }
-}
-
-void pulse_small::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> period;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> snr;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> thresh;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> score;
-    }
-}
-
-void pulse_small::parse(const std::string &s) {
-    SQL_ROW row(&s,20);
-    parse(row);
+std::string hotpix_tinysky::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
-template <> const char * const db_table<sah_pointing>::table_name="sah_pointing";
-template <> const char * db_table<sah_pointing>::_search_tag=table_name;
-template <> const int db_table<sah_pointing>::_nfields=7;
-template <> const char * const db_table<sah_pointing>::column_names[7]= {"time_id","time","ra","dec","q_pix","angle_range","bad"};
-
-sah_pointing::sah_pointing() :
-    db_table<sah_pointing>(*this,-1),
-    time_id(0),
-    time(0),
-    ra(0),
-    dec(0),
-    q_pix(0),
-    angle_range(0),
-    bad(0) {
-    db_open();
+std::string hotpix_tinysky::select_format() const
+{
+std::string rv("");
+for (int i=0; i<1;i++) rv+="?,";
+rv+="?";
+return rv;
 }
 
+std::string hotpix_tinysky::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
 
-sah_pointing::sah_pointing(const sah_pointing &a) :
-    db_table<sah_pointing>(*this,-1),
-    time_id(a.time_id),
-    time(a.time),
-    ra(a.ra),
-    dec(a.dec),
-    q_pix(a.q_pix),
-    angle_range(a.angle_range),
-    bad(a.bad) {
-    db_open();
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << last_hit_time;
+	return rv.str();
 }
 
 
-sah_pointing::sah_pointing(const SQL_ROW &a) :
-    db_table<sah_pointing>(*this,-1) {
-    db_open();
-    parse(a);
+std::string hotpix_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<last_hit_time>" << last_hit_time << "</last_hit_time>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void hotpix_tinysky::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"last_hit_time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> last_hit_time;
+	      }
+	      }
+	      }
+
+	void hotpix_tinysky::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> last_hit_time;
+	    }
+	      }
+
+	void hotpix_tinysky::parse(const std::string &s) {
+	      SQL_ROW row(&s,2);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<spike>::table_name="spike";
+template <> const char * db_table<spike>::_search_tag=table_name;
+template <> const int db_table<spike>::_nfields=16;
+template <> const char * const db_table<spike>::column_names[16]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
+
+spike::spike() : 
+	db_table<spike>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0)
+{
+	db_open();
+}
+
+
+spike::spike(const spike &a) : 
+	db_table<spike>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved)
+{
+	db_open();
 }
 
 
-sah_pointing::sah_pointing(const std::string &s,const char *tag) :
-    db_table<sah_pointing>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+spike::spike(const SQL_ROW &a) : 
+	db_table<spike>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-sah_pointing &sah_pointing::operator =(const sah_pointing &a) {
-    if (&a != this) {
-        time_id=a.time_id;
-        time=a.time;
-        ra=a.ra;
-        dec=a.dec;
-        q_pix=a.q_pix;
-        angle_range=a.angle_range;
-        bad=a.bad;
-    }
-    return (*this);
-}
-
-
-std::string sah_pointing::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<7; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string sah_pointing::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string sah_pointing::select_format() const {
-    std::string rv("");
-    for (int i=0; i<6; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string sah_pointing::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << time_id;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << dec;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << angle_range;
-    rv << ',';
-    rv << bad;
-    return rv.str();
-}
-
-
-std::string sah_pointing::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<time_id>" << time_id << "</time_id>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<dec>" << dec << "</dec>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<angle_range>" << angle_range << "</angle_range>\n";
-    rv << xml_indent() << "<bad>" << bad << "</bad>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void sah_pointing::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"time_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time_id;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"dec",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> dec;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"angle_range",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> angle_range;
-        }
-        if (extract_xml_record(field,"bad",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> bad;
-        }
-    }
-}
-
-void sah_pointing::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> time_id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> dec;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> angle_range;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> bad;
-    }
-}
-
-void sah_pointing::parse(const std::string &s) {
-    SQL_ROW row(&s,7);
-    parse(row);
+spike::spike(const std::string &s,const char *tag) : 
+	db_table<spike>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
-template <> const char * const db_table<sky_map>::table_name="sky_map";
-template <> const char * db_table<sky_map>::_search_tag=table_name;
-template <> const int db_table<sky_map>::_nfields=13;
-template <> const char * const db_table<sky_map>::column_names[13]= {"npix","qpix","fpix","spike_max_id","gaussian_max_id","pulse_max_id","triplet_max_id","spike_count","gaussian_count","pulse_count","triplet_count","new_data","score"};
-
-sky_map::sky_map() :
-    db_table<sky_map>(*this,-1),
-    npix(0),
-    qpix(0),
-    fpix(0),
-    spike_max_id(0),
-    gaussian_max_id(0),
-    pulse_max_id(0),
-    triplet_max_id(0),
-    spike_count(0),
-    gaussian_count(0),
-    pulse_count(0),
-    triplet_count(0),
-    new_data(0),
-    score(0) {
-    db_open();
-}
-
-
-sky_map::sky_map(const sky_map &a) :
-    db_table<sky_map>(*this,-1),
-    npix(a.npix),
-    qpix(a.qpix),
-    fpix(a.fpix),
-    spike_max_id(a.spike_max_id),
-    gaussian_max_id(a.gaussian_max_id),
-    pulse_max_id(a.pulse_max_id),
-    triplet_max_id(a.triplet_max_id),
-    spike_count(a.spike_count),
-    gaussian_count(a.gaussian_count),
-    pulse_count(a.pulse_count),
-    triplet_count(a.triplet_count),
-    new_data(a.new_data),
-    score(a.score) {
-    db_open();
-}
-
-
-sky_map::sky_map(const SQL_ROW &a) :
-    db_table<sky_map>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-sky_map::sky_map(const std::string &s,const char *tag) :
-    db_table<sky_map>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+
+spike &spike::operator =(const spike &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+	}
+	return (*this);
 }
 
 
-sky_map &sky_map::operator =(const sky_map &a) {
-    if (&a != this) {
-        npix=a.npix;
-        qpix=a.qpix;
-        fpix=a.fpix;
-        spike_max_id=a.spike_max_id;
-        gaussian_max_id=a.gaussian_max_id;
-        pulse_max_id=a.pulse_max_id;
-        triplet_max_id=a.triplet_max_id;
-        spike_count=a.spike_count;
-        gaussian_count=a.gaussian_count;
-        pulse_count=a.pulse_count;
-        triplet_count=a.triplet_count;
-        new_data=a.new_data;
-        score=a.score;
-    }
-    return (*this);
-}
-
-
-std::string sky_map::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<13; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string sky_map::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string sky_map::select_format() const {
-    std::string rv("");
-    for (int i=0; i<12; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string sky_map::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << npix;
-    rv << ',';
-    rv << qpix;
-    rv << ',';
-    rv << fpix;
-    rv << ',';
-    rv << spike_max_id;
-    rv << ',';
-    rv << gaussian_max_id;
-    rv << ',';
-    rv << pulse_max_id;
-    rv << ',';
-    rv << triplet_max_id;
-    rv << ',';
-    rv << spike_count;
-    rv << ',';
-    rv << gaussian_count;
-    rv << ',';
-    rv << pulse_count;
-    rv << ',';
-    rv << triplet_count;
-    rv << ',';
-    rv << new_data;
-    rv << ',';
-    rv << score;
-    return rv.str();
-}
-
-
-std::string sky_map::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<npix>" << npix << "</npix>\n";
-    rv << xml_indent() << "<qpix>" << qpix << "</qpix>\n";
-    rv << xml_indent() << "<fpix>" << fpix << "</fpix>\n";
-    rv << xml_indent() << "<spike_max_id>" << spike_max_id << "</spike_max_id>\n";
-    rv << xml_indent() << "<gaussian_max_id>" << gaussian_max_id << "</gaussian_max_id>\n";
-    rv << xml_indent() << "<pulse_max_id>" << pulse_max_id << "</pulse_max_id>\n";
-    rv << xml_indent() << "<triplet_max_id>" << triplet_max_id << "</triplet_max_id>\n";
-    rv << xml_indent() << "<spike_count>" << spike_count << "</spike_count>\n";
-    rv << xml_indent() << "<gaussian_count>" << gaussian_count << "</gaussian_count>\n";
-    rv << xml_indent() << "<pulse_count>" << pulse_count << "</pulse_count>\n";
-    rv << xml_indent() << "<triplet_count>" << triplet_count << "</triplet_count>\n";
-    rv << xml_indent() << "<new_data>" << new_data << "</new_data>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void sky_map::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"npix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> npix;
-        }
-        if (extract_xml_record(field,"qpix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> qpix;
-        }
-        if (extract_xml_record(field,"fpix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fpix;
-        }
-        if (extract_xml_record(field,"spike_max_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spike_max_id;
-        }
-        if (extract_xml_record(field,"gaussian_max_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gaussian_max_id;
-        }
-        if (extract_xml_record(field,"pulse_max_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_max_id;
-        }
-        if (extract_xml_record(field,"triplet_max_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_max_id;
-        }
-        if (extract_xml_record(field,"spike_count",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> spike_count;
-        }
-        if (extract_xml_record(field,"gaussian_count",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> gaussian_count;
-        }
-        if (extract_xml_record(field,"pulse_count",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> pulse_count;
-        }
-        if (extract_xml_record(field,"triplet_count",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> triplet_count;
-        }
-        if (extract_xml_record(field,"new_data",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> new_data;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-    }
-}
-
-void sky_map::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> npix;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> qpix;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> fpix;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> spike_max_id;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> gaussian_max_id;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> pulse_max_id;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> triplet_max_id;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> spike_count;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> gaussian_count;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> pulse_count;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> triplet_count;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> new_data;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> score;
-    }
-}
-
-void sky_map::parse(const std::string &s) {
-    SQL_ROW row(&s,13);
-    parse(row);
+std::string spike::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<16;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
-template <> const char * const db_table<hotpix>::table_name="hotpix";
-template <> const char * db_table<hotpix>::_search_tag=table_name;
-template <> const int db_table<hotpix>::_nfields=2;
-template <> const char * const db_table<hotpix>::column_names[2]= {"id","last_hit_time"};
 
-hotpix::hotpix() :
-    db_table<hotpix>(*this,-1),
-    id(0),
-    last_hit_time(0) {
-    db_open();
+std::string spike::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
+std::string spike::select_format() const
+{
+std::string rv("");
+for (int i=0; i<15;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string spike::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	return rv.str();
+}
+
+
+std::string spike::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void spike::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	      }
+	      }
+
+	void spike::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	      }
+
+	void spike::parse(const std::string &s) {
+	      SQL_ROW row(&s,16);
+	      parse(row);
+	      }
 
-hotpix::hotpix(const hotpix &a) :
-    db_table<hotpix>(*this,-1),
-    id(a.id),
-    last_hit_time(a.last_hit_time) {
-    db_open();
+template <> const char * const db_table<spike_small>::table_name="spike_small";
+template <> const char * db_table<spike_small>::_search_tag=table_name;
+template <> const int db_table<spike_small>::_nfields=16;
+template <> const char * const db_table<spike_small>::column_names[16]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
+
+spike_small::spike_small() : 
+	db_table<spike_small>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0)
+{
+	db_open();
+}
+
+
+spike_small::spike_small(const spike_small &a) : 
+	db_table<spike_small>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved)
+{
+	db_open();
 }
 
 
-hotpix::hotpix(const SQL_ROW &a) :
-    db_table<hotpix>(*this,-1) {
-    db_open();
-    parse(a);
+spike_small::spike_small(const SQL_ROW &a) : 
+	db_table<spike_small>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-hotpix::hotpix(const std::string &s,const char *tag) :
-    db_table<hotpix>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+spike_small::spike_small(const std::string &s,const char *tag) : 
+	db_table<spike_small>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-hotpix &hotpix::operator =(const hotpix &a) {
-    if (&a != this) {
-        id=a.id;
-        last_hit_time=a.last_hit_time;
-    }
-    return (*this);
+spike_small &spike_small::operator =(const spike_small &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+	}
+	return (*this);
 }
 
 
-std::string hotpix::update_format() const {
-    std::ostringstream rv("");
+std::string spike_small::update_format() const
+{	std::ostringstream rv("");
 
-    for (int i=2; i<2; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
+	for (int i=2;i<16;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-std::string hotpix::insert_format() const {
-    return std::string("?,")+update_format();
+std::string spike_small::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
-std::string hotpix::select_format() const {
-    std::string rv("");
-    for (int i=0; i<1; i++) rv+="?,";
-    rv+="?";
-    return rv;
+std::string spike_small::select_format() const
+{
+std::string rv("");
+for (int i=0; i<15;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string spike_small::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	return rv.str();
+}
+
+
+std::string spike_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void spike_small::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	      }
+	      }
+
+	void spike_small::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	      }
+
+	void spike_small::parse(const std::string &s) {
+	      SQL_ROW row(&s,16);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<autocorr>::table_name="autocorr";
+template <> const char * db_table<autocorr>::_search_tag=table_name;
+template <> const int db_table<autocorr>::_nfields=17;
+template <> const char * const db_table<autocorr>::column_names[17]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","delay","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
+
+autocorr::autocorr() : 
+	db_table<autocorr>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	delay(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0)
+{
+	db_open();
+}
+
+
+autocorr::autocorr(const autocorr &a) : 
+	db_table<autocorr>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	delay(a.delay),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved)
+{
+	db_open();
 }
 
-std::string hotpix::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
 
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << last_hit_time;
-    return rv.str();
+autocorr::autocorr(const SQL_ROW &a) : 
+	db_table<autocorr>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-std::string hotpix::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<last_hit_time>" << last_hit_time << "</last_hit_time>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
+autocorr::autocorr(const std::string &s,const char *tag) : 
+	db_table<autocorr>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-void hotpix::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"last_hit_time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> last_hit_time;
-        }
-    }
+autocorr &autocorr::operator =(const autocorr &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		delay=a.delay;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+	}
+	return (*this);
 }
 
-void hotpix::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> last_hit_time;
-    }
-}
 
-void hotpix::parse(const std::string &s) {
-    SQL_ROW row(&s,2);
-    parse(row);
-}
+std::string autocorr::update_format() const
+{	std::ostringstream rv("");
 
-template <> const char * const db_table<spike>::table_name="spike";
-template <> const char * db_table<spike>::_search_tag=table_name;
-template <> const int db_table<spike>::_nfields=16;
-template <> const char * const db_table<spike>::column_names[16]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
-
-spike::spike() :
-    db_table<spike>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0) {
-    db_open();
-}
-
-
-spike::spike(const spike &a) :
-    db_table<spike>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved) {
-    db_open();
-}
-
-
-spike::spike(const SQL_ROW &a) :
-    db_table<spike>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-spike::spike(const std::string &s,const char *tag) :
-    db_table<spike>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+	for (int i=2;i<17;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-spike &spike::operator =(const spike &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-    }
-    return (*this);
-}
-
-
-std::string spike::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<16; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string spike::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string spike::select_format() const {
-    std::string rv("");
-    for (int i=0; i<15; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string spike::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    return rv.str();
-}
-
-
-std::string spike::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void spike::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-    }
-}
-
-void spike::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-}
-
-void spike::parse(const std::string &s) {
-    SQL_ROW row(&s,16);
-    parse(row);
+std::string autocorr::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
-template <> const char * const db_table<spike_small>::table_name="spike_small";
-template <> const char * db_table<spike_small>::_search_tag=table_name;
-template <> const int db_table<spike_small>::_nfields=16;
-template <> const char * const db_table<spike_small>::column_names[16]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
-
-spike_small::spike_small() :
-    db_table<spike_small>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0) {
-    db_open();
-}
-
-
-spike_small::spike_small(const spike_small &a) :
-    db_table<spike_small>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved) {
-    db_open();
-}
-
-
-spike_small::spike_small(const SQL_ROW &a) :
-    db_table<spike_small>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-spike_small::spike_small(const std::string &s,const char *tag) :
-    db_table<spike_small>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+std::string autocorr::select_format() const
+{
+std::string rv("");
+for (int i=0; i<16;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string autocorr::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << delay;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	return rv.str();
+}
+
+
+std::string autocorr::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<delay>" << delay << "</delay>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void autocorr::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"delay",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> delay;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	      }
+	      }
+
+	void autocorr::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> delay;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> reserved;
+	    }
+	      }
+
+	void autocorr::parse(const std::string &s) {
+	      SQL_ROW row(&s,17);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<autocorr_small>::table_name="autocorr_small";
+template <> const char * db_table<autocorr_small>::_search_tag=table_name;
+template <> const int db_table<autocorr_small>::_nfields=17;
+template <> const char * const db_table<autocorr_small>::column_names[17]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","delay","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
+
+autocorr_small::autocorr_small() : 
+	db_table<autocorr_small>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	delay(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0)
+{
+	db_open();
+}
+
+
+autocorr_small::autocorr_small(const autocorr_small &a) : 
+	db_table<autocorr_small>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	delay(a.delay),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved)
+{
+	db_open();
 }
 
 
-spike_small &spike_small::operator =(const spike_small &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-    }
-    return (*this);
-}
-
-
-std::string spike_small::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<16; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string spike_small::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string spike_small::select_format() const {
-    std::string rv("");
-    for (int i=0; i<15; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string spike_small::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    return rv.str();
-}
-
-
-std::string spike_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void spike_small::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-    }
-}
-
-void spike_small::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-}
-
-void spike_small::parse(const std::string &s) {
-    SQL_ROW row(&s,16);
-    parse(row);
+autocorr_small::autocorr_small(const SQL_ROW &a) : 
+	db_table<autocorr_small>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
-template <> const char * const db_table<autocorr>::table_name="autocorr";
-template <> const char * db_table<autocorr>::_search_tag=table_name;
-template <> const int db_table<autocorr>::_nfields=17;
-template <> const char * const db_table<autocorr>::column_names[17]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","delay","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
-
-autocorr::autocorr() :
-    db_table<autocorr>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    delay(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0) {
-    db_open();
-}
-
-
-autocorr::autocorr(const autocorr &a) :
-    db_table<autocorr>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    delay(a.delay),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved) {
-    db_open();
-}
-
-
-autocorr::autocorr(const SQL_ROW &a) :
-    db_table<autocorr>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-autocorr::autocorr(const std::string &s,const char *tag) :
-    db_table<autocorr>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+
+autocorr_small::autocorr_small(const std::string &s,const char *tag) : 
+	db_table<autocorr_small>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-autocorr &autocorr::operator =(const autocorr &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        delay=a.delay;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-    }
-    return (*this);
-}
-
-
-std::string autocorr::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<17; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string autocorr::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string autocorr::select_format() const {
-    std::string rv("");
-    for (int i=0; i<16; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string autocorr::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << delay;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    return rv.str();
-}
-
-
-std::string autocorr::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<delay>" << delay << "</delay>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void autocorr::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"delay",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> delay;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-    }
-}
-
-void autocorr::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> delay;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> reserved;
-    }
-}
-
-void autocorr::parse(const std::string &s) {
-    SQL_ROW row(&s,17);
-    parse(row);
+autocorr_small &autocorr_small::operator =(const autocorr_small &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		delay=a.delay;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+	}
+	return (*this);
 }
 
-template <> const char * const db_table<autocorr_small>::table_name="autocorr_small";
-template <> const char * db_table<autocorr_small>::_search_tag=table_name;
-template <> const int db_table<autocorr_small>::_nfields=17;
-template <> const char * const db_table<autocorr_small>::column_names[17]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","delay","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
-
-autocorr_small::autocorr_small() :
-    db_table<autocorr_small>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    delay(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0) {
-    db_open();
-}
-
-
-autocorr_small::autocorr_small(const autocorr_small &a) :
-    db_table<autocorr_small>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    delay(a.delay),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved) {
-    db_open();
-}
-
-
-autocorr_small::autocorr_small(const SQL_ROW &a) :
-    db_table<autocorr_small>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-autocorr_small::autocorr_small(const std::string &s,const char *tag) :
-    db_table<autocorr_small>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+
+std::string autocorr_small::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<17;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-autocorr_small &autocorr_small::operator =(const autocorr_small &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        delay=a.delay;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-    }
-    return (*this);
-}
-
-
-std::string autocorr_small::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<17; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string autocorr_small::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string autocorr_small::select_format() const {
-    std::string rv("");
-    for (int i=0; i<16; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string autocorr_small::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << delay;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    return rv.str();
-}
-
-
-std::string autocorr_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<delay>" << delay << "</delay>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void autocorr_small::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"delay",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> delay;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-    }
-}
-
-void autocorr_small::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> delay;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> reserved;
-    }
-}
-
-void autocorr_small::parse(const std::string &s) {
-    SQL_ROW row(&s,17);
-    parse(row);
+std::string autocorr_small::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
+std::string autocorr_small::select_format() const
+{
+std::string rv("");
+for (int i=0; i<16;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string autocorr_small::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << delay;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	return rv.str();
+}
+
+
+std::string autocorr_small::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<delay>" << delay << "</delay>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void autocorr_small::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"delay",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> delay;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	      }
+	      }
+
+	void autocorr_small::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> delay;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> reserved;
+	    }
+	      }
+
+	void autocorr_small::parse(const std::string &s) {
+	      SQL_ROW row(&s,17);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<classic_versions>::table_name="classic_versions";
 template <> const char * db_table<classic_versions>::_search_tag=table_name;
 template <> const int db_table<classic_versions>::_nfields=10;
-template <> const char * const db_table<classic_versions>::column_names[10]= {"id","ver_major","ver_minor","platformid","comment","filename","md5_cksum","sum_cksum","cksum_cksum","file_cksum"};
+template <> const char * const db_table<classic_versions>::column_names[10]={"id","ver_major","ver_minor","platformid","comment","filename","md5_cksum","sum_cksum","cksum_cksum","file_cksum"};
+
+classic_versions::classic_versions() : 
+	db_table<classic_versions>(*this,-1),
+	id(0),
+	ver_major(0),
+	ver_minor(0),
+	platformid(0),
+	file_cksum(0)
+{
+	db_open();
+	comment[0]=0;
+	filename[0]=0;
+	md5_cksum[0]=0;
+	sum_cksum[0]=0;
+	cksum_cksum[0]=0;
+}
+
+
+classic_versions::classic_versions(const classic_versions &a) : 
+	db_table<classic_versions>(*this,-1),
+	id(a.id),
+	ver_major(a.ver_major),
+	ver_minor(a.ver_minor),
+	platformid(a.platformid),
+	file_cksum(a.file_cksum)
+{
+	db_open();
+	strcpy(comment,a.comment);
+	strcpy(filename,a.filename);
+	strcpy(md5_cksum,a.md5_cksum);
+	strcpy(sum_cksum,a.sum_cksum);
+	strcpy(cksum_cksum,a.cksum_cksum);
+}
 
-classic_versions::classic_versions() :
-    db_table<classic_versions>(*this,-1),
-    id(0),
-    ver_major(0),
-    ver_minor(0),
-    platformid(0),
-    file_cksum(0) {
-    db_open();
-    comment[0]=0;
-    filename[0]=0;
-    md5_cksum[0]=0;
-    sum_cksum[0]=0;
-    cksum_cksum[0]=0;
+
+classic_versions::classic_versions(const SQL_ROW &a) : 
+	db_table<classic_versions>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-classic_versions::classic_versions(const classic_versions &a) :
-    db_table<classic_versions>(*this,-1),
-    id(a.id),
-    ver_major(a.ver_major),
-    ver_minor(a.ver_minor),
-    platformid(a.platformid),
-    file_cksum(a.file_cksum) {
-    db_open();
-    strcpy(comment,a.comment);
-    strcpy(filename,a.filename);
-    strcpy(md5_cksum,a.md5_cksum);
-    strcpy(sum_cksum,a.sum_cksum);
-    strcpy(cksum_cksum,a.cksum_cksum);
+classic_versions::classic_versions(const std::string &s,const char *tag) : 
+	db_table<classic_versions>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
-classic_versions::classic_versions(const SQL_ROW &a) :
-    db_table<classic_versions>(*this,-1) {
-    db_open();
-    parse(a);
+classic_versions &classic_versions::operator =(const classic_versions &a) {
+	if (&a != this) {
+		id=a.id;
+		ver_major=a.ver_major;
+		ver_minor=a.ver_minor;
+		platformid=a.platformid;
+		file_cksum=a.file_cksum;
+	strcpy(comment,a.comment);
+	strcpy(filename,a.filename);
+	strcpy(md5_cksum,a.md5_cksum);
+	strcpy(sum_cksum,a.sum_cksum);
+	strcpy(cksum_cksum,a.cksum_cksum);
+	}
+	return (*this);
 }
 
 
-classic_versions::classic_versions(const std::string &s,const char *tag) :
-    db_table<classic_versions>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+std::string classic_versions::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<10;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-classic_versions &classic_versions::operator =(const classic_versions &a) {
-    if (&a != this) {
-        id=a.id;
-        ver_major=a.ver_major;
-        ver_minor=a.ver_minor;
-        platformid=a.platformid;
-        file_cksum=a.file_cksum;
-        strcpy(comment,a.comment);
-        strcpy(filename,a.filename);
-        strcpy(md5_cksum,a.md5_cksum);
-        strcpy(sum_cksum,a.sum_cksum);
-        strcpy(cksum_cksum,a.cksum_cksum);
-    }
-    return (*this);
-}
-
-
-std::string classic_versions::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<10; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string classic_versions::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string classic_versions::select_format() const {
-    std::string rv("");
-    for (int i=0; i<9; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string classic_versions::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << ver_major;
-    rv << ',';
-    rv << ver_minor;
-    rv << ',';
-    rv << platformid;
-    rv << ',';
-    rv << "'" << comment << "'";
-    rv << ',';
-    rv << "'" << filename << "'";
-    rv << ',';
-    rv << "'" << md5_cksum << "'";
-    rv << ',';
-    rv << "'" << sum_cksum << "'";
-    rv << ',';
-    rv << "'" << cksum_cksum << "'";
-    rv << ',';
-    rv << file_cksum;
-    return rv.str();
-}
-
-
-std::string classic_versions::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<ver_major>" << ver_major << "</ver_major>\n";
-    rv << xml_indent() << "<ver_minor>" << ver_minor << "</ver_minor>\n";
-    rv << xml_indent() << "<platformid>" << platformid << "</platformid>\n";
-    {
-        std::string enc_field=xml_encode_string(comment,std::min(strlen(comment),sizeof(comment)));
-        rv << xml_indent() << "<comment>";
-        rv << enc_field << "</comment>\n";
-    }
-    {
-        std::string enc_field=xml_encode_string(filename,std::min(strlen(filename),sizeof(filename)));
-        rv << xml_indent() << "<filename>";
-        rv << enc_field << "</filename>\n";
-    }
-    {
-        std::string enc_field=xml_encode_string(md5_cksum,std::min(strlen(md5_cksum),sizeof(md5_cksum)));
-        rv << xml_indent() << "<md5_cksum>";
-        rv << enc_field << "</md5_cksum>\n";
-    }
-    {
-        std::string enc_field=xml_encode_string(sum_cksum,std::min(strlen(sum_cksum),sizeof(sum_cksum)));
-        rv << xml_indent() << "<sum_cksum>";
-        rv << enc_field << "</sum_cksum>\n";
-    }
-    {
-        std::string enc_field=xml_encode_string(cksum_cksum,std::min(strlen(cksum_cksum),sizeof(cksum_cksum)));
-        rv << xml_indent() << "<cksum_cksum>";
-        rv << enc_field << "</cksum_cksum>\n";
-    }
-    rv << xml_indent() << "<file_cksum>" << file_cksum << "</file_cksum>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void classic_versions::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"ver_major",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ver_major;
-        }
-        if (extract_xml_record(field,"ver_minor",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ver_minor;
-        }
-        if (extract_xml_record(field,"platformid",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> platformid;
-        }
-        if (extract_xml_record(field,"comment",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(comment,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
-            comment[std::min(in.size(),(size_t)253)]=0;
-        }
-        if (extract_xml_record(field,"filename",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(filename,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
-            filename[std::min(in.size(),(size_t)253)]=0;
-        }
-        if (extract_xml_record(field,"md5_cksum",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(md5_cksum,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
-            md5_cksum[std::min(in.size(),(size_t)253)]=0;
-        }
-        if (extract_xml_record(field,"sum_cksum",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(sum_cksum,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
-            sum_cksum[std::min(in.size(),(size_t)253)]=0;
-        }
-        if (extract_xml_record(field,"cksum_cksum",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(cksum_cksum,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
-            cksum_cksum[std::min(in.size(),(size_t)253)]=0;
-        }
-        if (extract_xml_record(field,"file_cksum",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> file_cksum;
-        }
-    }
-}
-
-void classic_versions::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> ver_major;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> ver_minor;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> platformid;
-    }
-    {
-        strncpy(comment,s[4]->c_str(),254);
-        comment[253]=0;
-    }
-    {
-        strncpy(filename,s[5]->c_str(),254);
-        filename[253]=0;
-    }
-    {
-        strncpy(md5_cksum,s[6]->c_str(),254);
-        md5_cksum[253]=0;
-    }
-    {
-        strncpy(sum_cksum,s[7]->c_str(),254);
-        sum_cksum[253]=0;
-    }
-    {
-        strncpy(cksum_cksum,s[8]->c_str(),254);
-        cksum_cksum[253]=0;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> file_cksum;
-    }
-}
-
-void classic_versions::parse(const std::string &s) {
-    SQL_ROW row(&s,10);
-    parse(row);
+std::string classic_versions::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
+std::string classic_versions::select_format() const
+{
+std::string rv("");
+for (int i=0; i<9;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string classic_versions::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << ver_major;
+	rv << ',';
+	rv << ver_minor;
+	rv << ',';
+	rv << platformid;
+	rv << ',';
+	rv << "'" << comment << "'";
+	rv << ',';
+	rv << "'" << filename << "'";
+	rv << ',';
+	rv << "'" << md5_cksum << "'";
+	rv << ',';
+	rv << "'" << sum_cksum << "'";
+	rv << ',';
+	rv << "'" << cksum_cksum << "'";
+	rv << ',';
+	rv << file_cksum;
+	return rv.str();
+}
+
+
+std::string classic_versions::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<ver_major>" << ver_major << "</ver_major>\n";
+	rv << xml_indent() << "<ver_minor>" << ver_minor << "</ver_minor>\n";
+	rv << xml_indent() << "<platformid>" << platformid << "</platformid>\n";
+	{
+	  std::string enc_field=xml_encode_string(comment,std::min(strlen(comment),sizeof(comment)));
+	  rv << xml_indent() << "<comment>";
+	  rv << enc_field << "</comment>\n";
+	}
+	{
+	  std::string enc_field=xml_encode_string(filename,std::min(strlen(filename),sizeof(filename)));
+	  rv << xml_indent() << "<filename>";
+	  rv << enc_field << "</filename>\n";
+	}
+	{
+	  std::string enc_field=xml_encode_string(md5_cksum,std::min(strlen(md5_cksum),sizeof(md5_cksum)));
+	  rv << xml_indent() << "<md5_cksum>";
+	  rv << enc_field << "</md5_cksum>\n";
+	}
+	{
+	  std::string enc_field=xml_encode_string(sum_cksum,std::min(strlen(sum_cksum),sizeof(sum_cksum)));
+	  rv << xml_indent() << "<sum_cksum>";
+	  rv << enc_field << "</sum_cksum>\n";
+	}
+	{
+	  std::string enc_field=xml_encode_string(cksum_cksum,std::min(strlen(cksum_cksum),sizeof(cksum_cksum)));
+	  rv << xml_indent() << "<cksum_cksum>";
+	  rv << enc_field << "</cksum_cksum>\n";
+	}
+	rv << xml_indent() << "<file_cksum>" << file_cksum << "</file_cksum>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void classic_versions::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"ver_major",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ver_major;
+	      }
+	    if (extract_xml_record(field,"ver_minor",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ver_minor;
+	      }
+	    if (extract_xml_record(field,"platformid",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> platformid;
+	      }
+	    if (extract_xml_record(field,"comment",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(comment,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
+	        comment[std::min(in.size(),(size_t)253)]=0;
+	      }
+	    if (extract_xml_record(field,"filename",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(filename,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
+	        filename[std::min(in.size(),(size_t)253)]=0;
+	      }
+	    if (extract_xml_record(field,"md5_cksum",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(md5_cksum,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
+	        md5_cksum[std::min(in.size(),(size_t)253)]=0;
+	      }
+	    if (extract_xml_record(field,"sum_cksum",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(sum_cksum,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
+	        sum_cksum[std::min(in.size(),(size_t)253)]=0;
+	      }
+	    if (extract_xml_record(field,"cksum_cksum",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(cksum_cksum,(const char *)&(in.front()),std::min(in.size(),(size_t)254));
+	        cksum_cksum[std::min(in.size(),(size_t)253)]=0;
+	      }
+	    if (extract_xml_record(field,"file_cksum",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> file_cksum;
+	      }
+	      }
+	      }
+
+	void classic_versions::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> ver_major;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> ver_minor;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> platformid;
+	    }
+	  {  
+	        strncpy(comment,s[4]->c_str(),254);
+	        comment[253]=0;
+	    }
+	  {  
+	        strncpy(filename,s[5]->c_str(),254);
+	        filename[253]=0;
+	    }
+	  {  
+	        strncpy(md5_cksum,s[6]->c_str(),254);
+	        md5_cksum[253]=0;
+	    }
+	  {  
+	        strncpy(sum_cksum,s[7]->c_str(),254);
+	        sum_cksum[253]=0;
+	    }
+	  {  
+	        strncpy(cksum_cksum,s[8]->c_str(),254);
+	        cksum_cksum[253]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> file_cksum;
+	    }
+	      }
+
+	void classic_versions::parse(const std::string &s) {
+	      SQL_ROW row(&s,10);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<classic_active_versions>::table_name="classic_active_versions";
 template <> const char * db_table<classic_active_versions>::_search_tag=table_name;
 template <> const int db_table<classic_active_versions>::_nfields=4;
-template <> const char * const db_table<classic_active_versions>::column_names[4]= {"id","versionid","ver_major","ver_minor"};
-
-classic_active_versions::classic_active_versions() :
-    db_table<classic_active_versions>(*this,-1),
-    id(0),
-    versionid(0),
-    ver_major(0),
-    ver_minor(0) {
-    db_open();
+template <> const char * const db_table<classic_active_versions>::column_names[4]={"id","versionid","ver_major","ver_minor"};
+
+classic_active_versions::classic_active_versions() : 
+	db_table<classic_active_versions>(*this,-1),
+	id(0),
+	versionid(0),
+	ver_major(0),
+	ver_minor(0)
+{
+	db_open();
 }
 
 
-classic_active_versions::classic_active_versions(const classic_active_versions &a) :
-    db_table<classic_active_versions>(*this,-1),
-    id(a.id),
-    versionid(a.versionid),
-    ver_major(a.ver_major),
-    ver_minor(a.ver_minor) {
-    db_open();
+classic_active_versions::classic_active_versions(const classic_active_versions &a) : 
+	db_table<classic_active_versions>(*this,-1),
+	id(a.id),
+	versionid(a.versionid),
+	ver_major(a.ver_major),
+	ver_minor(a.ver_minor)
+{
+	db_open();
 }
 
 
-classic_active_versions::classic_active_versions(const SQL_ROW &a) :
-    db_table<classic_active_versions>(*this,-1) {
-    db_open();
-    parse(a);
+classic_active_versions::classic_active_versions(const SQL_ROW &a) : 
+	db_table<classic_active_versions>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-classic_active_versions::classic_active_versions(const std::string &s,const char *tag) :
-    db_table<classic_active_versions>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+classic_active_versions::classic_active_versions(const std::string &s,const char *tag) : 
+	db_table<classic_active_versions>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
 classic_active_versions &classic_active_versions::operator =(const classic_active_versions &a) {
-    if (&a != this) {
-        id=a.id;
-        versionid=a.versionid;
-        ver_major=a.ver_major;
-        ver_minor=a.ver_minor;
-    }
-    return (*this);
-}
-
-
-std::string classic_active_versions::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<4; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string classic_active_versions::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string classic_active_versions::select_format() const {
-    std::string rv("");
-    for (int i=0; i<3; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string classic_active_versions::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << versionid;
-    rv << ',';
-    rv << ver_major;
-    rv << ',';
-    rv << ver_minor;
-    return rv.str();
-}
-
-
-std::string classic_active_versions::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<versionid>" << versionid << "</versionid>\n";
-    rv << xml_indent() << "<ver_major>" << ver_major << "</ver_major>\n";
-    rv << xml_indent() << "<ver_minor>" << ver_minor << "</ver_minor>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void classic_active_versions::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"versionid",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> versionid;
-        }
-        if (extract_xml_record(field,"ver_major",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ver_major;
-        }
-        if (extract_xml_record(field,"ver_minor",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ver_minor;
-        }
-    }
-}
-
-void classic_active_versions::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> versionid;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> ver_major;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> ver_minor;
-    }
-}
-
-void classic_active_versions::parse(const std::string &s) {
-    SQL_ROW row(&s,4);
-    parse(row);
+	if (&a != this) {
+		id=a.id;
+		versionid=a.versionid;
+		ver_major=a.ver_major;
+		ver_minor=a.ver_minor;
+	}
+	return (*this);
 }
 
-template <> const char * const db_table<classic_active_versionids>::table_name="classic_active_versionids";
-template <> const char * db_table<classic_active_versionids>::_search_tag=table_name;
-template <> const int db_table<classic_active_versionids>::_nfields=2;
-template <> const char * const db_table<classic_active_versionids>::column_names[2]= {"id","versionid"};
 
-classic_active_versionids::classic_active_versionids() :
-    db_table<classic_active_versionids>(*this,-1),
-    id(0),
-    versionid(0) {
-    db_open();
+std::string classic_active_versions::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<4;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-classic_active_versionids::classic_active_versionids(const classic_active_versionids &a) :
-    db_table<classic_active_versionids>(*this,-1),
-    id(a.id),
-    versionid(a.versionid) {
-    db_open();
+std::string classic_active_versions::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
-
-classic_active_versionids::classic_active_versionids(const SQL_ROW &a) :
-    db_table<classic_active_versionids>(*this,-1) {
-    db_open();
-    parse(a);
+std::string classic_active_versions::select_format() const
+{
+std::string rv("");
+for (int i=0; i<3;i++) rv+="?,";
+rv+="?";
+return rv;
 }
 
+std::string classic_active_versions::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
 
-classic_active_versionids::classic_active_versionids(const std::string &s,const char *tag) :
-    db_table<classic_active_versionids>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << versionid;
+	rv << ',';
+	rv << ver_major;
+	rv << ',';
+	rv << ver_minor;
+	return rv.str();
 }
 
 
-classic_active_versionids &classic_active_versionids::operator =(const classic_active_versionids &a) {
-    if (&a != this) {
-        id=a.id;
-        versionid=a.versionid;
-    }
-    return (*this);
-}
+std::string classic_active_versions::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<versionid>" << versionid << "</versionid>\n";
+	rv << xml_indent() << "<ver_major>" << ver_major << "</ver_major>\n";
+	rv << xml_indent() << "<ver_minor>" << ver_minor << "</ver_minor>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void classic_active_versions::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"versionid",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> versionid;
+	      }
+	    if (extract_xml_record(field,"ver_major",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ver_major;
+	      }
+	    if (extract_xml_record(field,"ver_minor",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ver_minor;
+	      }
+	      }
+	      }
+
+	void classic_active_versions::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> versionid;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> ver_major;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> ver_minor;
+	    }
+	      }
+
+	void classic_active_versions::parse(const std::string &s) {
+	      SQL_ROW row(&s,4);
+	      parse(row);
+	      }
+
+template <> const char * const db_table<classic_active_versionids>::table_name="classic_active_versionids";
+template <> const char * db_table<classic_active_versionids>::_search_tag=table_name;
+template <> const int db_table<classic_active_versionids>::_nfields=2;
+template <> const char * const db_table<classic_active_versionids>::column_names[2]={"id","versionid"};
 
+classic_active_versionids::classic_active_versionids() : 
+	db_table<classic_active_versionids>(*this,-1),
+	id(0),
+	versionid(0)
+{
+	db_open();
+}
 
-std::string classic_active_versionids::update_format() const {
-    std::ostringstream rv("");
 
-    for (int i=2; i<2; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
+classic_active_versionids::classic_active_versionids(const classic_active_versionids &a) : 
+	db_table<classic_active_versionids>(*this,-1),
+	id(a.id),
+	versionid(a.versionid)
+{
+	db_open();
 }
 
 
-std::string classic_active_versionids::insert_format() const {
-    return std::string("?,")+update_format();
+classic_active_versionids::classic_active_versionids(const SQL_ROW &a) : 
+	db_table<classic_active_versionids>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
-std::string classic_active_versionids::select_format() const {
-    std::string rv("");
-    for (int i=0; i<1; i++) rv+="?,";
-    rv+="?";
-    return rv;
+
+classic_active_versionids::classic_active_versionids(const std::string &s,const char *tag) : 
+	db_table<classic_active_versionids>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
-std::string classic_active_versionids::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
 
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << versionid;
-    return rv.str();
+classic_active_versionids &classic_active_versionids::operator =(const classic_active_versionids &a) {
+	if (&a != this) {
+		id=a.id;
+		versionid=a.versionid;
+	}
+	return (*this);
 }
 
 
-std::string classic_active_versionids::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
+std::string classic_active_versionids::update_format() const
+{	std::ostringstream rv("");
 
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<versionid>" << versionid << "</versionid>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
+	for (int i=2;i<2;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
 
-void classic_active_versionids::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"versionid",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> versionid;
-        }
-    }
+std::string classic_active_versionids::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
-void classic_active_versionids::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> versionid;
-    }
+std::string classic_active_versionids::select_format() const
+{
+std::string rv("");
+for (int i=0; i<1;i++) rv+="?,";
+rv+="?";
+return rv;
 }
 
-void classic_active_versionids::parse(const std::string &s) {
-    SQL_ROW row(&s,2);
-    parse(row);
+std::string classic_active_versionids::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << versionid;
+	return rv.str();
 }
 
+
+std::string classic_active_versionids::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<versionid>" << versionid << "</versionid>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void classic_active_versionids::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"versionid",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> versionid;
+	      }
+	      }
+	      }
+
+	void classic_active_versionids::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> versionid;
+	    }
+	      }
+
+	void classic_active_versionids::parse(const std::string &s) {
+	      SQL_ROW row(&s,2);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<rfi_zone>::table_name="rfi_zone";
 template <> const char * db_table<rfi_zone>::_search_tag=table_name;
 template <> const int db_table<rfi_zone>::_nfields=26;
-template <> const char * const db_table<rfi_zone>::column_names[26]= {"id","min_receiver_s4id","max_receiver_s4id","min_splitter_config","max_splitter_config","min_analysis_config","max_analysis_config","min_tape_id","max_tape_id","min_workunit_id","max_workunit_id","min_result_id","max_result_id","min_time","max_time","central_baseband_freq","baseband_freq_width","central_detection_freq","detection_freq_width","central_period","period_width","fft_len_flags","signal_type_flags","ra","dec [...]
-
-rfi_zone::rfi_zone() :
-    db_table<rfi_zone>(*this,-1),
-    id(0),
-    min_receiver_s4id(0),
-    max_receiver_s4id(0),
-    min_splitter_config(0),
-    max_splitter_config(0),
-    min_analysis_config(0),
-    max_analysis_config(0),
-    min_tape_id(0),
-    max_tape_id(0),
-    min_workunit_id(0),
-    max_workunit_id(0),
-    min_result_id(0),
-    max_result_id(0),
-    min_time(0),
-    max_time(0),
-    central_baseband_freq(0),
-    baseband_freq_width(0),
-    central_detection_freq(0),
-    detection_freq_width(0),
-    central_period(0),
-    period_width(0),
-    fft_len_flags(0),
-    signal_type_flags(0),
-    ra(0),
-    dec(0),
-    angular_distance(0) {
-    db_open();
-}
-
-
-rfi_zone::rfi_zone(const rfi_zone &a) :
-    db_table<rfi_zone>(*this,-1),
-    id(a.id),
-    min_receiver_s4id(a.min_receiver_s4id),
-    max_receiver_s4id(a.max_receiver_s4id),
-    min_splitter_config(a.min_splitter_config),
-    max_splitter_config(a.max_splitter_config),
-    min_analysis_config(a.min_analysis_config),
-    max_analysis_config(a.max_analysis_config),
-    min_tape_id(a.min_tape_id),
-    max_tape_id(a.max_tape_id),
-    min_workunit_id(a.min_workunit_id),
-    max_workunit_id(a.max_workunit_id),
-    min_result_id(a.min_result_id),
-    max_result_id(a.max_result_id),
-    min_time(a.min_time),
-    max_time(a.max_time),
-    central_baseband_freq(a.central_baseband_freq),
-    baseband_freq_width(a.baseband_freq_width),
-    central_detection_freq(a.central_detection_freq),
-    detection_freq_width(a.detection_freq_width),
-    central_period(a.central_period),
-    period_width(a.period_width),
-    fft_len_flags(a.fft_len_flags),
-    signal_type_flags(a.signal_type_flags),
-    ra(a.ra),
-    dec(a.dec),
-    angular_distance(a.angular_distance) {
-    db_open();
-}
-
-
-rfi_zone::rfi_zone(const SQL_ROW &a) :
-    db_table<rfi_zone>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-rfi_zone::rfi_zone(const std::string &s,const char *tag) :
-    db_table<rfi_zone>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+template <> const char * const db_table<rfi_zone>::column_names[26]={"id","min_receiver_s4id","max_receiver_s4id","min_splitter_config","max_splitter_config","min_analysis_config","max_analysis_config","min_tape_id","max_tape_id","min_workunit_id","max_workunit_id","min_result_id","max_result_id","min_time","max_time","central_baseband_freq","baseband_freq_width","central_detection_freq","detection_freq_width","central_period","period_width","fft_len_flags","signal_type_flags","ra","dec" [...]
+
+rfi_zone::rfi_zone() : 
+	db_table<rfi_zone>(*this,-1),
+	id(0),
+	min_receiver_s4id(0),
+	max_receiver_s4id(0),
+	min_splitter_config(0),
+	max_splitter_config(0),
+	min_analysis_config(0),
+	max_analysis_config(0),
+	min_tape_id(0),
+	max_tape_id(0),
+	min_workunit_id(0),
+	max_workunit_id(0),
+	min_result_id(0),
+	max_result_id(0),
+	min_time(0),
+	max_time(0),
+	central_baseband_freq(0),
+	baseband_freq_width(0),
+	central_detection_freq(0),
+	detection_freq_width(0),
+	central_period(0),
+	period_width(0),
+	fft_len_flags(0),
+	signal_type_flags(0),
+	ra(0),
+	dec(0),
+	angular_distance(0)
+{
+	db_open();
+}
+
+
+rfi_zone::rfi_zone(const rfi_zone &a) : 
+	db_table<rfi_zone>(*this,-1),
+	id(a.id),
+	min_receiver_s4id(a.min_receiver_s4id),
+	max_receiver_s4id(a.max_receiver_s4id),
+	min_splitter_config(a.min_splitter_config),
+	max_splitter_config(a.max_splitter_config),
+	min_analysis_config(a.min_analysis_config),
+	max_analysis_config(a.max_analysis_config),
+	min_tape_id(a.min_tape_id),
+	max_tape_id(a.max_tape_id),
+	min_workunit_id(a.min_workunit_id),
+	max_workunit_id(a.max_workunit_id),
+	min_result_id(a.min_result_id),
+	max_result_id(a.max_result_id),
+	min_time(a.min_time),
+	max_time(a.max_time),
+	central_baseband_freq(a.central_baseband_freq),
+	baseband_freq_width(a.baseband_freq_width),
+	central_detection_freq(a.central_detection_freq),
+	detection_freq_width(a.detection_freq_width),
+	central_period(a.central_period),
+	period_width(a.period_width),
+	fft_len_flags(a.fft_len_flags),
+	signal_type_flags(a.signal_type_flags),
+	ra(a.ra),
+	dec(a.dec),
+	angular_distance(a.angular_distance)
+{
+	db_open();
 }
 
 
-rfi_zone &rfi_zone::operator =(const rfi_zone &a) {
-    if (&a != this) {
-        id=a.id;
-        min_receiver_s4id=a.min_receiver_s4id;
-        max_receiver_s4id=a.max_receiver_s4id;
-        min_splitter_config=a.min_splitter_config;
-        max_splitter_config=a.max_splitter_config;
-        min_analysis_config=a.min_analysis_config;
-        max_analysis_config=a.max_analysis_config;
-        min_tape_id=a.min_tape_id;
-        max_tape_id=a.max_tape_id;
-        min_workunit_id=a.min_workunit_id;
-        max_workunit_id=a.max_workunit_id;
-        min_result_id=a.min_result_id;
-        max_result_id=a.max_result_id;
-        min_time=a.min_time;
-        max_time=a.max_time;
-        central_baseband_freq=a.central_baseband_freq;
-        baseband_freq_width=a.baseband_freq_width;
-        central_detection_freq=a.central_detection_freq;
-        detection_freq_width=a.detection_freq_width;
-        central_period=a.central_period;
-        period_width=a.period_width;
-        fft_len_flags=a.fft_len_flags;
-        signal_type_flags=a.signal_type_flags;
-        ra=a.ra;
-        dec=a.dec;
-        angular_distance=a.angular_distance;
-    }
-    return (*this);
-}
-
-
-std::string rfi_zone::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<26; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string rfi_zone::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string rfi_zone::select_format() const {
-    std::string rv("");
-    for (int i=0; i<25; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string rfi_zone::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    rv << min_receiver_s4id;
-    rv << ',';
-    rv << max_receiver_s4id;
-    rv << ',';
-    rv << min_splitter_config;
-    rv << ',';
-    rv << max_splitter_config;
-    rv << ',';
-    rv << min_analysis_config;
-    rv << ',';
-    rv << max_analysis_config;
-    rv << ',';
-    rv << min_tape_id;
-    rv << ',';
-    rv << max_tape_id;
-    rv << ',';
-    rv << min_workunit_id;
-    rv << ',';
-    rv << max_workunit_id;
-    rv << ',';
-    rv << min_result_id;
-    rv << ',';
-    rv << max_result_id;
-    rv << ',';
-    rv << min_time;
-    rv << ',';
-    rv << max_time;
-    rv << ',';
-    rv << central_baseband_freq;
-    rv << ',';
-    rv << baseband_freq_width;
-    rv << ',';
-    rv << central_detection_freq;
-    rv << ',';
-    rv << detection_freq_width;
-    rv << ',';
-    rv << central_period;
-    rv << ',';
-    rv << period_width;
-    rv << ',';
-    rv << fft_len_flags;
-    rv << ',';
-    rv << signal_type_flags;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << dec;
-    rv << ',';
-    rv << angular_distance;
-    return rv.str();
-}
-
-
-std::string rfi_zone::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    rv << xml_indent() << "<min_receiver_s4id>" << min_receiver_s4id << "</min_receiver_s4id>\n";
-    rv << xml_indent() << "<max_receiver_s4id>" << max_receiver_s4id << "</max_receiver_s4id>\n";
-    rv << xml_indent() << "<min_splitter_config>" << min_splitter_config << "</min_splitter_config>\n";
-    rv << xml_indent() << "<max_splitter_config>" << max_splitter_config << "</max_splitter_config>\n";
-    rv << xml_indent() << "<min_analysis_config>" << min_analysis_config << "</min_analysis_config>\n";
-    rv << xml_indent() << "<max_analysis_config>" << max_analysis_config << "</max_analysis_config>\n";
-    rv << xml_indent() << "<min_tape_id>" << min_tape_id << "</min_tape_id>\n";
-    rv << xml_indent() << "<max_tape_id>" << max_tape_id << "</max_tape_id>\n";
-    rv << xml_indent() << "<min_workunit_id>" << min_workunit_id << "</min_workunit_id>\n";
-    rv << xml_indent() << "<max_workunit_id>" << max_workunit_id << "</max_workunit_id>\n";
-    rv << xml_indent() << "<min_result_id>" << min_result_id << "</min_result_id>\n";
-    rv << xml_indent() << "<max_result_id>" << max_result_id << "</max_result_id>\n";
-    rv << xml_indent() << "<min_time>" << min_time << "</min_time>\n";
-    rv << xml_indent() << "<max_time>" << max_time << "</max_time>\n";
-    rv << xml_indent() << "<central_baseband_freq>" << central_baseband_freq << "</central_baseband_freq>\n";
-    rv << xml_indent() << "<baseband_freq_width>" << baseband_freq_width << "</baseband_freq_width>\n";
-    rv << xml_indent() << "<central_detection_freq>" << central_detection_freq << "</central_detection_freq>\n";
-    rv << xml_indent() << "<detection_freq_width>" << detection_freq_width << "</detection_freq_width>\n";
-    rv << xml_indent() << "<central_period>" << central_period << "</central_period>\n";
-    rv << xml_indent() << "<period_width>" << period_width << "</period_width>\n";
-    rv << xml_indent() << "<fft_len_flags>" << fft_len_flags << "</fft_len_flags>\n";
-    rv << xml_indent() << "<signal_type_flags>" << signal_type_flags << "</signal_type_flags>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<dec>" << dec << "</dec>\n";
-    rv << xml_indent() << "<angular_distance>" << angular_distance << "</angular_distance>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void rfi_zone::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"min_receiver_s4id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_receiver_s4id;
-        }
-        if (extract_xml_record(field,"max_receiver_s4id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_receiver_s4id;
-        }
-        if (extract_xml_record(field,"min_splitter_config",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_splitter_config;
-        }
-        if (extract_xml_record(field,"max_splitter_config",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_splitter_config;
-        }
-        if (extract_xml_record(field,"min_analysis_config",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_analysis_config;
-        }
-        if (extract_xml_record(field,"max_analysis_config",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_analysis_config;
-        }
-        if (extract_xml_record(field,"min_tape_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_tape_id;
-        }
-        if (extract_xml_record(field,"max_tape_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_tape_id;
-        }
-        if (extract_xml_record(field,"min_workunit_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_workunit_id;
-        }
-        if (extract_xml_record(field,"max_workunit_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_workunit_id;
-        }
-        if (extract_xml_record(field,"min_result_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_result_id;
-        }
-        if (extract_xml_record(field,"max_result_id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_result_id;
-        }
-        if (extract_xml_record(field,"min_time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> min_time;
-        }
-        if (extract_xml_record(field,"max_time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_time;
-        }
-        if (extract_xml_record(field,"central_baseband_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> central_baseband_freq;
-        }
-        if (extract_xml_record(field,"baseband_freq_width",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> baseband_freq_width;
-        }
-        if (extract_xml_record(field,"central_detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> central_detection_freq;
-        }
-        if (extract_xml_record(field,"detection_freq_width",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq_width;
-        }
-        if (extract_xml_record(field,"central_period",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> central_period;
-        }
-        if (extract_xml_record(field,"period_width",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> period_width;
-        }
-        if (extract_xml_record(field,"fft_len_flags",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len_flags;
-        }
-        if (extract_xml_record(field,"signal_type_flags",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> signal_type_flags;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"dec",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> dec;
-        }
-        if (extract_xml_record(field,"angular_distance",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> angular_distance;
-        }
-    }
-}
-
-void rfi_zone::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> min_receiver_s4id;
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> max_receiver_s4id;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> min_splitter_config;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> max_splitter_config;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> min_analysis_config;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> max_analysis_config;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> min_tape_id;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> max_tape_id;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> min_workunit_id;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> max_workunit_id;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> min_result_id;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> max_result_id;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> min_time;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> max_time;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> central_baseband_freq;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> baseband_freq_width;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> central_detection_freq;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> detection_freq_width;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> central_period;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> period_width;
-    }
-    {
-        std::istringstream row(*(s[21]));
-        row >> fft_len_flags;
-    }
-    {
-        std::istringstream row(*(s[22]));
-        row >> signal_type_flags;
-    }
-    {
-        std::istringstream row(*(s[23]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[24]));
-        row >> dec;
-    }
-    {
-        std::istringstream row(*(s[25]));
-        row >> angular_distance;
-    }
-}
-
-void rfi_zone::parse(const std::string &s) {
-    SQL_ROW row(&s,26);
-    parse(row);
+rfi_zone::rfi_zone(const SQL_ROW &a) : 
+	db_table<rfi_zone>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+rfi_zone::rfi_zone(const std::string &s,const char *tag) : 
+	db_table<rfi_zone>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
+
+rfi_zone &rfi_zone::operator =(const rfi_zone &a) {
+	if (&a != this) {
+		id=a.id;
+		min_receiver_s4id=a.min_receiver_s4id;
+		max_receiver_s4id=a.max_receiver_s4id;
+		min_splitter_config=a.min_splitter_config;
+		max_splitter_config=a.max_splitter_config;
+		min_analysis_config=a.min_analysis_config;
+		max_analysis_config=a.max_analysis_config;
+		min_tape_id=a.min_tape_id;
+		max_tape_id=a.max_tape_id;
+		min_workunit_id=a.min_workunit_id;
+		max_workunit_id=a.max_workunit_id;
+		min_result_id=a.min_result_id;
+		max_result_id=a.max_result_id;
+		min_time=a.min_time;
+		max_time=a.max_time;
+		central_baseband_freq=a.central_baseband_freq;
+		baseband_freq_width=a.baseband_freq_width;
+		central_detection_freq=a.central_detection_freq;
+		detection_freq_width=a.detection_freq_width;
+		central_period=a.central_period;
+		period_width=a.period_width;
+		fft_len_flags=a.fft_len_flags;
+		signal_type_flags=a.signal_type_flags;
+		ra=a.ra;
+		dec=a.dec;
+		angular_distance=a.angular_distance;
+	}
+	return (*this);
+}
+
+
+std::string rfi_zone::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<26;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string rfi_zone::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string rfi_zone::select_format() const
+{
+std::string rv("");
+for (int i=0; i<25;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string rfi_zone::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	rv << min_receiver_s4id;
+	rv << ',';
+	rv << max_receiver_s4id;
+	rv << ',';
+	rv << min_splitter_config;
+	rv << ',';
+	rv << max_splitter_config;
+	rv << ',';
+	rv << min_analysis_config;
+	rv << ',';
+	rv << max_analysis_config;
+	rv << ',';
+	rv << min_tape_id;
+	rv << ',';
+	rv << max_tape_id;
+	rv << ',';
+	rv << min_workunit_id;
+	rv << ',';
+	rv << max_workunit_id;
+	rv << ',';
+	rv << min_result_id;
+	rv << ',';
+	rv << max_result_id;
+	rv << ',';
+	rv << min_time;
+	rv << ',';
+	rv << max_time;
+	rv << ',';
+	rv << central_baseband_freq;
+	rv << ',';
+	rv << baseband_freq_width;
+	rv << ',';
+	rv << central_detection_freq;
+	rv << ',';
+	rv << detection_freq_width;
+	rv << ',';
+	rv << central_period;
+	rv << ',';
+	rv << period_width;
+	rv << ',';
+	rv << fft_len_flags;
+	rv << ',';
+	rv << signal_type_flags;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << dec;
+	rv << ',';
+	rv << angular_distance;
+	return rv.str();
+}
+
+
+std::string rfi_zone::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	rv << xml_indent() << "<min_receiver_s4id>" << min_receiver_s4id << "</min_receiver_s4id>\n";
+	rv << xml_indent() << "<max_receiver_s4id>" << max_receiver_s4id << "</max_receiver_s4id>\n";
+	rv << xml_indent() << "<min_splitter_config>" << min_splitter_config << "</min_splitter_config>\n";
+	rv << xml_indent() << "<max_splitter_config>" << max_splitter_config << "</max_splitter_config>\n";
+	rv << xml_indent() << "<min_analysis_config>" << min_analysis_config << "</min_analysis_config>\n";
+	rv << xml_indent() << "<max_analysis_config>" << max_analysis_config << "</max_analysis_config>\n";
+	rv << xml_indent() << "<min_tape_id>" << min_tape_id << "</min_tape_id>\n";
+	rv << xml_indent() << "<max_tape_id>" << max_tape_id << "</max_tape_id>\n";
+	rv << xml_indent() << "<min_workunit_id>" << min_workunit_id << "</min_workunit_id>\n";
+	rv << xml_indent() << "<max_workunit_id>" << max_workunit_id << "</max_workunit_id>\n";
+	rv << xml_indent() << "<min_result_id>" << min_result_id << "</min_result_id>\n";
+	rv << xml_indent() << "<max_result_id>" << max_result_id << "</max_result_id>\n";
+	rv << xml_indent() << "<min_time>" << min_time << "</min_time>\n";
+	rv << xml_indent() << "<max_time>" << max_time << "</max_time>\n";
+	rv << xml_indent() << "<central_baseband_freq>" << central_baseband_freq << "</central_baseband_freq>\n";
+	rv << xml_indent() << "<baseband_freq_width>" << baseband_freq_width << "</baseband_freq_width>\n";
+	rv << xml_indent() << "<central_detection_freq>" << central_detection_freq << "</central_detection_freq>\n";
+	rv << xml_indent() << "<detection_freq_width>" << detection_freq_width << "</detection_freq_width>\n";
+	rv << xml_indent() << "<central_period>" << central_period << "</central_period>\n";
+	rv << xml_indent() << "<period_width>" << period_width << "</period_width>\n";
+	rv << xml_indent() << "<fft_len_flags>" << fft_len_flags << "</fft_len_flags>\n";
+	rv << xml_indent() << "<signal_type_flags>" << signal_type_flags << "</signal_type_flags>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<dec>" << dec << "</dec>\n";
+	rv << xml_indent() << "<angular_distance>" << angular_distance << "</angular_distance>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void rfi_zone::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"min_receiver_s4id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_receiver_s4id;
+	      }
+	    if (extract_xml_record(field,"max_receiver_s4id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_receiver_s4id;
+	      }
+	    if (extract_xml_record(field,"min_splitter_config",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_splitter_config;
+	      }
+	    if (extract_xml_record(field,"max_splitter_config",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_splitter_config;
+	      }
+	    if (extract_xml_record(field,"min_analysis_config",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_analysis_config;
+	      }
+	    if (extract_xml_record(field,"max_analysis_config",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_analysis_config;
+	      }
+	    if (extract_xml_record(field,"min_tape_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_tape_id;
+	      }
+	    if (extract_xml_record(field,"max_tape_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_tape_id;
+	      }
+	    if (extract_xml_record(field,"min_workunit_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_workunit_id;
+	      }
+	    if (extract_xml_record(field,"max_workunit_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_workunit_id;
+	      }
+	    if (extract_xml_record(field,"min_result_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_result_id;
+	      }
+	    if (extract_xml_record(field,"max_result_id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_result_id;
+	      }
+	    if (extract_xml_record(field,"min_time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> min_time;
+	      }
+	    if (extract_xml_record(field,"max_time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_time;
+	      }
+	    if (extract_xml_record(field,"central_baseband_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> central_baseband_freq;
+	      }
+	    if (extract_xml_record(field,"baseband_freq_width",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> baseband_freq_width;
+	      }
+	    if (extract_xml_record(field,"central_detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> central_detection_freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq_width",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq_width;
+	      }
+	    if (extract_xml_record(field,"central_period",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> central_period;
+	      }
+	    if (extract_xml_record(field,"period_width",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> period_width;
+	      }
+	    if (extract_xml_record(field,"fft_len_flags",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len_flags;
+	      }
+	    if (extract_xml_record(field,"signal_type_flags",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> signal_type_flags;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"dec",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> dec;
+	      }
+	    if (extract_xml_record(field,"angular_distance",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> angular_distance;
+	      }
+	      }
+	      }
+
+	void rfi_zone::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> min_receiver_s4id;
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> max_receiver_s4id;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> min_splitter_config;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> max_splitter_config;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> min_analysis_config;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> max_analysis_config;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> min_tape_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> max_tape_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> min_workunit_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> max_workunit_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> min_result_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> max_result_id;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> min_time;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> max_time;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> central_baseband_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> baseband_freq_width;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> central_detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> detection_freq_width;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> central_period;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> period_width;
+	    }
+	  {  
+	        std::istringstream row(*(s[21]));
+	        row >> fft_len_flags;
+	    }
+	  {  
+	        std::istringstream row(*(s[22]));
+	        row >> signal_type_flags;
+	    }
+	  {  
+	        std::istringstream row(*(s[23]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[24]));
+	        row >> dec;
+	    }
+	  {  
+	        std::istringstream row(*(s[25]));
+	        row >> angular_distance;
+	    }
+	      }
+
+	void rfi_zone::parse(const std::string &s) {
+	      SQL_ROW row(&s,26);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<bad_data>::table_name="bad_data";
 template <> const char * db_table<bad_data>::_search_tag=table_name;
 template <> const int db_table<bad_data>::_nfields=3;
-template <> const char * const db_table<bad_data>::column_names[3]= {"name","beam""reason"};
+template <> const char * const db_table<bad_data>::column_names[3]={"name","beam""reason"};
 
-bad_data::bad_data() :
-    db_table<bad_data>(*this,-1),
-    beam(0) {
-    db_open();
-    name[0]=0;
-    reason[0]=0;
+bad_data::bad_data() : 
+	db_table<bad_data>(*this,-1),
+	beam(0)
+{
+	db_open();
+	name[0]=0;
+	reason[0]=0;
 }
 
 
-bad_data::bad_data(const bad_data &a) :
-    db_table<bad_data>(*this,-1),
-    beam(a.beam) {
-    db_open();
-    strcpy(name,a.name);
-    strcpy(reason,a.reason);
+bad_data::bad_data(const bad_data &a) : 
+	db_table<bad_data>(*this,-1),
+	beam(a.beam)
+{
+	db_open();
+	strcpy(name,a.name);
+	strcpy(reason,a.reason);
 }
 
 
-bad_data::bad_data(const SQL_ROW &a) :
-    db_table<bad_data>(*this,-1) {
-    db_open();
-    parse(a);
+bad_data::bad_data(const SQL_ROW &a) : 
+	db_table<bad_data>(*this,-1)
+{
+	db_open();
+	parse(a);
 }
 
 
-bad_data::bad_data(const std::string &s,const char *tag) :
-    db_table<bad_data>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+bad_data::bad_data(const std::string &s,const char *tag) : 
+	db_table<bad_data>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
 bad_data &bad_data::operator =(const bad_data &a) {
-    if (&a != this) {
-        beam=a.beam;
-        strcpy(name,a.name);
-        strcpy(reason,a.reason);
-    }
-    return (*this);
-}
-
-
-std::string bad_data::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<3; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string bad_data::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string bad_data::select_format() const {
-    std::string rv("");
-    for (int i=0; i<2; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string bad_data::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << "'" << name << "'";
-    rv << ',';
-    rv << beam;
-    rv << ',';
-    rv << "'" << reason << "'";
-    return rv.str();
-}
-
-
-std::string bad_data::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    {
-        std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
-        rv << xml_indent() << "<name>";
-        rv << enc_field << "</name>\n";
-    }
-    rv << xml_indent() << "<beam>" << beam << "</beam>\n";
-    {
-        std::string enc_field=xml_encode_string(reason,std::min(strlen(reason),sizeof(reason)));
-        rv << xml_indent() << "<reason>";
-        rv << enc_field << "</reason>\n";
-    }
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void bad_data::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"name",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)20));
-            name[std::min(in.size(),(size_t)19)]=0;
-        }
-        if (extract_xml_record(field,"beam",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> beam;
-        }
-        if (extract_xml_record(field,"reason",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::string::size_type epos=sub.find("<",pos);
-            if (epos==std::string::npos) epos=sub.find('\n',pos);
-            if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
-            std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
-            strncpy(reason,(const char *)&(in.front()),std::min(in.size(),(size_t)255));
-            reason[std::min(in.size(),(size_t)254)]=0;
-        }
-    }
-}
-
-void bad_data::parse(const SQL_ROW &s) {
-    {
-        strncpy(name,s[0]->c_str(),20);
-        name[19]=0;
-    }
-    {
-        std::istringstream row(*(s[1]));
-        row >> beam;
-    }
-    {
-        strncpy(reason,s[2]->c_str(),255);
-        reason[254]=0;
-    }
-}
-
-void bad_data::parse(const std::string &s) {
-    SQL_ROW row(&s,3);
-    parse(row);
+	if (&a != this) {
+		beam=a.beam;
+	strcpy(name,a.name);
+	strcpy(reason,a.reason);
+	}
+	return (*this);
+}
+
+
+std::string bad_data::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<3;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string bad_data::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string bad_data::select_format() const
+{
+std::string rv("");
+for (int i=0; i<2;i++) rv+="?,";
+rv+="?";
+return rv;
 }
 
+std::string bad_data::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << "'" << name << "'";
+	rv << ',';
+	rv << beam;
+	rv << ',';
+	rv << "'" << reason << "'";
+	return rv.str();
+}
+
+
+std::string bad_data::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	{
+	  std::string enc_field=xml_encode_string(name,std::min(strlen(name),sizeof(name)));
+	  rv << xml_indent() << "<name>";
+	  rv << enc_field << "</name>\n";
+	}
+	rv << xml_indent() << "<beam>" << beam << "</beam>\n";
+	{
+	  std::string enc_field=xml_encode_string(reason,std::min(strlen(reason),sizeof(reason)));
+	  rv << xml_indent() << "<reason>";
+	  rv << enc_field << "</reason>\n";
+	}
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void bad_data::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"name",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(name,(const char *)&(in.front()),std::min(in.size(),(size_t)128));
+	        name[std::min(in.size(),(size_t)127)]=0;
+	      }
+	    if (extract_xml_record(field,"beam",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> beam;
+	      }
+	    if (extract_xml_record(field,"reason",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::string::size_type epos=sub.find("<",pos);
+	        if (epos==std::string::npos) epos=sub.find('\n',pos);
+	        if (epos==std::string::npos) epos=pos+strlen(sub.c_str()+pos);
+	        std::vector<unsigned char> in(xml_decode_string<unsigned char>((const char *)sub.c_str()+pos,epos-pos));
+	        strncpy(reason,(const char *)&(in.front()),std::min(in.size(),(size_t)255));
+	        reason[std::min(in.size(),(size_t)254)]=0;
+	      }
+	      }
+	      }
+
+	void bad_data::parse(const SQL_ROW &s) {
+	  {  
+	        strncpy(name,s[0]->c_str(),128);
+	        name[127]=0;
+	    }
+	  {  
+	        std::istringstream row(*(s[1]));
+	        row >> beam;
+	    }
+	  {  
+	        strncpy(reason,s[2]->c_str(),255);
+	        reason[254]=0;
+	    }
+	      }
+
+	void bad_data::parse(const std::string &s) {
+	      SQL_ROW row(&s,3);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<spike_tinysky>::table_name="spike_tinysky";
 template <> const char * db_table<spike_tinysky>::_search_tag=table_name;
 template <> const int db_table<spike_tinysky>::_nfields=16;
-template <> const char * const db_table<spike_tinysky>::column_names[16]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
-
-spike_tinysky::spike_tinysky() :
-    db_table<spike_tinysky>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0) {
-    db_open();
-}
-
-
-spike_tinysky::spike_tinysky(const spike_tinysky &a) :
-    db_table<spike_tinysky>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved) {
-    db_open();
-}
-
-
-spike_tinysky::spike_tinysky(const SQL_ROW &a) :
-    db_table<spike_tinysky>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-spike_tinysky::spike_tinysky(const std::string &s,const char *tag) :
-    db_table<spike_tinysky>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+template <> const char * const db_table<spike_tinysky>::column_names[16]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
+
+spike_tinysky::spike_tinysky() : 
+	db_table<spike_tinysky>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0)
+{
+	db_open();
+}
+
+
+spike_tinysky::spike_tinysky(const spike_tinysky &a) : 
+	db_table<spike_tinysky>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved)
+{
+	db_open();
+}
+
+
+spike_tinysky::spike_tinysky(const SQL_ROW &a) : 
+	db_table<spike_tinysky>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+spike_tinysky::spike_tinysky(const std::string &s,const char *tag) : 
+	db_table<spike_tinysky>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
 spike_tinysky &spike_tinysky::operator =(const spike_tinysky &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-    }
-    return (*this);
-}
-
-
-std::string spike_tinysky::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<16; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string spike_tinysky::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string spike_tinysky::select_format() const {
-    std::string rv("");
-    for (int i=0; i<15; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string spike_tinysky::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    return rv.str();
-}
-
-
-std::string spike_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void spike_tinysky::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-    }
-}
-
-void spike_tinysky::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-}
-
-void spike_tinysky::parse(const std::string &s) {
-    SQL_ROW row(&s,16);
-    parse(row);
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+	}
+	return (*this);
+}
+
+
+std::string spike_tinysky::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<16;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
 }
 
+
+std::string spike_tinysky::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string spike_tinysky::select_format() const
+{
+std::string rv("");
+for (int i=0; i<15;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string spike_tinysky::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	return rv.str();
+}
+
+
+std::string spike_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void spike_tinysky::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	      }
+	      }
+
+	void spike_tinysky::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	      }
+
+	void spike_tinysky::parse(const std::string &s) {
+	      SQL_ROW row(&s,16);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<gaussian_tinysky>::table_name="gaussian_tinysky";
 template <> const char * db_table<gaussian_tinysky>::_search_tag=table_name;
 template <> const int db_table<gaussian_tinysky>::_nfields=22;
-template <> const char * const db_table<gaussian_tinysky>::column_names[22]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","sigma","chisqr","null_chisqr","score","max_power","pot"};
-
-gaussian_tinysky::gaussian_tinysky() :
-    db_table<gaussian_tinysky>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0),
-    sigma(0),
-    chisqr(0),
-    null_chisqr(0),
-    score(0),
-    max_power(0),
-    pot((unsigned char *)0,0,_x_csv) {
-    db_open();
-}
-
-
-gaussian_tinysky::gaussian_tinysky(const gaussian_tinysky &a) :
-    db_table<gaussian_tinysky>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved),
-    sigma(a.sigma),
-    chisqr(a.chisqr),
-    null_chisqr(a.null_chisqr),
-    score(a.score),
-    max_power(a.max_power),
-    pot(a.pot) {
-    db_open();
-}
-
-
-gaussian_tinysky::gaussian_tinysky(const SQL_ROW &a) :
-    db_table<gaussian_tinysky>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-gaussian_tinysky::gaussian_tinysky(const std::string &s,const char *tag) :
-    db_table<gaussian_tinysky>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+template <> const char * const db_table<gaussian_tinysky>::column_names[22]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","sigma","chisqr","null_chisqr","score","max_power","pot"};
+
+gaussian_tinysky::gaussian_tinysky() : 
+	db_table<gaussian_tinysky>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0),
+	sigma(0),
+	chisqr(0),
+	null_chisqr(0),
+	score(0),
+	max_power(0),
+	pot((unsigned char *)0,0,_x_csv)
+{
+	db_open();
+}
+
+
+gaussian_tinysky::gaussian_tinysky(const gaussian_tinysky &a) : 
+	db_table<gaussian_tinysky>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved),
+	sigma(a.sigma),
+	chisqr(a.chisqr),
+	null_chisqr(a.null_chisqr),
+	score(a.score),
+	max_power(a.max_power),
+	pot(a.pot)
+{
+	db_open();
 }
 
 
-gaussian_tinysky &gaussian_tinysky::operator =(const gaussian_tinysky &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-        sigma=a.sigma;
-        chisqr=a.chisqr;
-        null_chisqr=a.null_chisqr;
-        score=a.score;
-        max_power=a.max_power;
-        pot=a.pot;
-    }
-    return (*this);
-}
-
-
-std::string gaussian_tinysky::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<22; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string gaussian_tinysky::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string gaussian_tinysky::select_format() const {
-    std::string rv("");
-    for (int i=0; i<21; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string gaussian_tinysky::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << sigma;
-    rv << ',';
-    rv << chisqr;
-    rv << ',';
-    rv << null_chisqr;
-    rv << ',';
-    rv << score;
-    rv << ',';
-    rv << max_power;
-    rv << ',';
-    rv << "<BYTE len=" << std::max(pot.size()*2,(size_t)1) << ">" << pot.print_hex() ;
-    return rv.str();
-}
-
-
-std::string gaussian_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<sigma>" << sigma << "</sigma>\n";
-    rv << xml_indent() << "<chisqr>" << chisqr << "</chisqr>\n";
-    rv << xml_indent() << "<null_chisqr>" << null_chisqr << "</null_chisqr>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    rv << xml_indent() << "<max_power>" << max_power << "</max_power>\n";
-    if (pot.size()) {
-        std::string enc_field=xml_encode_string(pot,pot.encoding);
-        rv << xml_indent() << "<pot length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[pot.encoding] << "\">";
-        rv << enc_field << "</pot>\n";
-    }
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void gaussian_tinysky::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"sigma",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> sigma;
-        }
-        if (extract_xml_record(field,"chisqr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chisqr;
-        }
-        if (extract_xml_record(field,"null_chisqr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> null_chisqr;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-        if (extract_xml_record(field,"max_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> max_power;
-        }
-        if (extract_xml_record(field,"pot",sub)) {
-            std::istringstream in(sub.c_str());
-            in >> pot;
-        }
-    }
-}
-
-void gaussian_tinysky::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> sigma;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> chisqr;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> null_chisqr;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> score;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> max_power;
-    }
-    {
-        pot=sqlblob<unsigned char>(*(s[21]));
-    }
-}
-
-void gaussian_tinysky::parse(const std::string &s) {
-    SQL_ROW row(&s,22);
-    parse(row);
+gaussian_tinysky::gaussian_tinysky(const SQL_ROW &a) : 
+	db_table<gaussian_tinysky>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+gaussian_tinysky::gaussian_tinysky(const std::string &s,const char *tag) : 
+	db_table<gaussian_tinysky>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
+
+gaussian_tinysky &gaussian_tinysky::operator =(const gaussian_tinysky &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+		sigma=a.sigma;
+		chisqr=a.chisqr;
+		null_chisqr=a.null_chisqr;
+		score=a.score;
+		max_power=a.max_power;
+		pot=a.pot;
+	}
+	return (*this);
+}
+
+
+std::string gaussian_tinysky::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<22;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string gaussian_tinysky::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string gaussian_tinysky::select_format() const
+{
+std::string rv("");
+for (int i=0; i<21;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string gaussian_tinysky::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << sigma;
+	rv << ',';
+	rv << chisqr;
+	rv << ',';
+	rv << null_chisqr;
+	rv << ',';
+	rv << score;
+	rv << ',';
+	rv << max_power;
+	rv << ',';
+	rv << "<BYTE len=" << std::max(pot.size()*2,(size_t)1) << ">" << pot.print_hex() ;
+	return rv.str();
+}
+
+
+std::string gaussian_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<sigma>" << sigma << "</sigma>\n";
+	rv << xml_indent() << "<chisqr>" << chisqr << "</chisqr>\n";
+	rv << xml_indent() << "<null_chisqr>" << null_chisqr << "</null_chisqr>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	rv << xml_indent() << "<max_power>" << max_power << "</max_power>\n";
+	if (pot.size()) {
+	  std::string enc_field=xml_encode_string(pot,pot.encoding);
+	  rv << xml_indent() << "<pot length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[pot.encoding] << "\">"; 
+	  rv << enc_field << "</pot>\n";
+	}
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void gaussian_tinysky::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"sigma",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> sigma;
+	      }
+	    if (extract_xml_record(field,"chisqr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chisqr;
+	      }
+	    if (extract_xml_record(field,"null_chisqr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> null_chisqr;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	    if (extract_xml_record(field,"max_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> max_power;
+	      }
+	    if (extract_xml_record(field,"pot",sub)) {
+	        std::istringstream in(sub.c_str());
+	        in >> pot;
+	      }
+	      }
+	      }
+
+	void gaussian_tinysky::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> sigma;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> chisqr;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> null_chisqr;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> score;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> max_power;
+	    }
+	  {  
+	        pot=sqlblob<unsigned char>(*(s[21]));
+	    }
+	      }
+
+	void gaussian_tinysky::parse(const std::string &s) {
+	      SQL_ROW row(&s,22);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<pulse_tinysky>::table_name="pulse_tinysky";
 template <> const char * db_table<pulse_tinysky>::_search_tag=table_name;
 template <> const int db_table<pulse_tinysky>::_nfields=22;
-template <> const char * const db_table<pulse_tinysky>::column_names[22]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period","snr","thresh","score","len_prof","pot"};
-
-pulse_tinysky::pulse_tinysky() :
-    db_table<pulse_tinysky>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0),
-    period(0),
-    snr(0),
-    thresh(0),
-    score(0),
-    len_prof(0),
-    pot((unsigned char *)0,0,_x_csv) {
-    db_open();
-}
-
-
-pulse_tinysky::pulse_tinysky(const pulse_tinysky &a) :
-    db_table<pulse_tinysky>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved),
-    period(a.period),
-    snr(a.snr),
-    thresh(a.thresh),
-    score(a.score),
-    len_prof(a.len_prof),
-    pot(a.pot) {
-    db_open();
-}
-
-
-pulse_tinysky::pulse_tinysky(const SQL_ROW &a) :
-    db_table<pulse_tinysky>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-pulse_tinysky::pulse_tinysky(const std::string &s,const char *tag) :
-    db_table<pulse_tinysky>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+template <> const char * const db_table<pulse_tinysky>::column_names[22]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period","snr","thresh","score","len_prof","pot"};
+
+pulse_tinysky::pulse_tinysky() : 
+	db_table<pulse_tinysky>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0),
+	period(0),
+	snr(0),
+	thresh(0),
+	score(0),
+	len_prof(0),
+	pot((unsigned char *)0,0,_x_csv)
+{
+	db_open();
+}
+
+
+pulse_tinysky::pulse_tinysky(const pulse_tinysky &a) : 
+	db_table<pulse_tinysky>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved),
+	period(a.period),
+	snr(a.snr),
+	thresh(a.thresh),
+	score(a.score),
+	len_prof(a.len_prof),
+	pot(a.pot)
+{
+	db_open();
 }
 
 
-pulse_tinysky &pulse_tinysky::operator =(const pulse_tinysky &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-        period=a.period;
-        snr=a.snr;
-        thresh=a.thresh;
-        score=a.score;
-        len_prof=a.len_prof;
-        pot=a.pot;
-    }
-    return (*this);
-}
-
-
-std::string pulse_tinysky::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<22; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string pulse_tinysky::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string pulse_tinysky::select_format() const {
-    std::string rv("");
-    for (int i=0; i<21; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string pulse_tinysky::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << period;
-    rv << ',';
-    rv << snr;
-    rv << ',';
-    rv << thresh;
-    rv << ',';
-    rv << score;
-    rv << ',';
-    rv << len_prof;
-    rv << ',';
-    rv << "<BYTE len=" << std::max(pot.size()*2,(size_t)1) << ">" << pot.print_hex() ;
-    return rv.str();
-}
-
-
-std::string pulse_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<period>" << period << "</period>\n";
-    rv << xml_indent() << "<snr>" << snr << "</snr>\n";
-    rv << xml_indent() << "<thresh>" << thresh << "</thresh>\n";
-    rv << xml_indent() << "<score>" << score << "</score>\n";
-    rv << xml_indent() << "<len_prof>" << len_prof << "</len_prof>\n";
-    if (pot.size()) {
-        std::string enc_field=xml_encode_string(pot,pot.encoding);
-        rv << xml_indent() << "<pot length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[pot.encoding] << "\">";
-        rv << enc_field << "</pot>\n";
-    }
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void pulse_tinysky::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"period",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> period;
-        }
-        if (extract_xml_record(field,"snr",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> snr;
-        }
-        if (extract_xml_record(field,"thresh",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> thresh;
-        }
-        if (extract_xml_record(field,"score",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> score;
-        }
-        if (extract_xml_record(field,"len_prof",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> len_prof;
-        }
-        if (extract_xml_record(field,"pot",sub)) {
-            std::istringstream in(sub.c_str());
-            in >> pot;
-        }
-    }
-}
-
-void pulse_tinysky::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> period;
-    }
-    {
-        std::istringstream row(*(s[17]));
-        row >> snr;
-    }
-    {
-        std::istringstream row(*(s[18]));
-        row >> thresh;
-    }
-    {
-        std::istringstream row(*(s[19]));
-        row >> score;
-    }
-    {
-        std::istringstream row(*(s[20]));
-        row >> len_prof;
-    }
-    {
-        pot=sqlblob<unsigned char>(*(s[21]));
-    }
-}
-
-void pulse_tinysky::parse(const std::string &s) {
-    SQL_ROW row(&s,22);
-    parse(row);
+pulse_tinysky::pulse_tinysky(const SQL_ROW &a) : 
+	db_table<pulse_tinysky>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+pulse_tinysky::pulse_tinysky(const std::string &s,const char *tag) : 
+	db_table<pulse_tinysky>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
+
+pulse_tinysky &pulse_tinysky::operator =(const pulse_tinysky &a) {
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+		period=a.period;
+		snr=a.snr;
+		thresh=a.thresh;
+		score=a.score;
+		len_prof=a.len_prof;
+		pot=a.pot;
+	}
+	return (*this);
+}
+
+
+std::string pulse_tinysky::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<22;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string pulse_tinysky::insert_format() const
+{	return std::string("?,")+update_format();
+}
+
+std::string pulse_tinysky::select_format() const
+{
+std::string rv("");
+for (int i=0; i<21;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string pulse_tinysky::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << period;
+	rv << ',';
+	rv << snr;
+	rv << ',';
+	rv << thresh;
+	rv << ',';
+	rv << score;
+	rv << ',';
+	rv << len_prof;
+	rv << ',';
+	rv << "<BYTE len=" << std::max(pot.size()*2,(size_t)1) << ">" << pot.print_hex() ;
+	return rv.str();
+}
+
+
+std::string pulse_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<period>" << period << "</period>\n";
+	rv << xml_indent() << "<snr>" << snr << "</snr>\n";
+	rv << xml_indent() << "<thresh>" << thresh << "</thresh>\n";
+	rv << xml_indent() << "<score>" << score << "</score>\n";
+	rv << xml_indent() << "<len_prof>" << len_prof << "</len_prof>\n";
+	if (pot.size()) {
+	  std::string enc_field=xml_encode_string(pot,pot.encoding);
+	  rv << xml_indent() << "<pot length=" << enc_field.size() << " encoding=\"" << xml_encoding_names[pot.encoding] << "\">"; 
+	  rv << enc_field << "</pot>\n";
+	}
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void pulse_tinysky::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"period",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> period;
+	      }
+	    if (extract_xml_record(field,"snr",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> snr;
+	      }
+	    if (extract_xml_record(field,"thresh",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> thresh;
+	      }
+	    if (extract_xml_record(field,"score",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> score;
+	      }
+	    if (extract_xml_record(field,"len_prof",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> len_prof;
+	      }
+	    if (extract_xml_record(field,"pot",sub)) {
+	        std::istringstream in(sub.c_str());
+	        in >> pot;
+	      }
+	      }
+	      }
+
+	void pulse_tinysky::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> period;
+	    }
+	  {  
+	        std::istringstream row(*(s[17]));
+	        row >> snr;
+	    }
+	  {  
+	        std::istringstream row(*(s[18]));
+	        row >> thresh;
+	    }
+	  {  
+	        std::istringstream row(*(s[19]));
+	        row >> score;
+	    }
+	  {  
+	        std::istringstream row(*(s[20]));
+	        row >> len_prof;
+	    }
+	  {  
+	        pot=sqlblob<unsigned char>(*(s[21]));
+	    }
+	      }
+
+	void pulse_tinysky::parse(const std::string &s) {
+	      SQL_ROW row(&s,22);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<triplet_tinysky>::table_name="triplet_tinysky";
 template <> const char * db_table<triplet_tinysky>::_search_tag=table_name;
 template <> const int db_table<triplet_tinysky>::_nfields=17;
-template <> const char * const db_table<triplet_tinysky>::column_names[17]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period"};
-
-triplet_tinysky::triplet_tinysky() :
-    db_table<triplet_tinysky>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0),
-    period(0) {
-    db_open();
-}
-
-
-triplet_tinysky::triplet_tinysky(const triplet_tinysky &a) :
-    db_table<triplet_tinysky>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved),
-    period(a.period) {
-    db_open();
-}
-
-
-triplet_tinysky::triplet_tinysky(const SQL_ROW &a) :
-    db_table<triplet_tinysky>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-triplet_tinysky::triplet_tinysky(const std::string &s,const char *tag) :
-    db_table<triplet_tinysky>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+template <> const char * const db_table<triplet_tinysky>::column_names[17]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved","period"};
+
+triplet_tinysky::triplet_tinysky() : 
+	db_table<triplet_tinysky>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0),
+	period(0)
+{
+	db_open();
+}
+
+
+triplet_tinysky::triplet_tinysky(const triplet_tinysky &a) : 
+	db_table<triplet_tinysky>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved),
+	period(a.period)
+{
+	db_open();
+}
+
+
+triplet_tinysky::triplet_tinysky(const SQL_ROW &a) : 
+	db_table<triplet_tinysky>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+triplet_tinysky::triplet_tinysky(const std::string &s,const char *tag) : 
+	db_table<triplet_tinysky>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
 triplet_tinysky &triplet_tinysky::operator =(const triplet_tinysky &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-        period=a.period;
-    }
-    return (*this);
-}
-
-
-std::string triplet_tinysky::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<17; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string triplet_tinysky::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string triplet_tinysky::select_format() const {
-    std::string rv("");
-    for (int i=0; i<16; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string triplet_tinysky::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    rv << ',';
-    rv << period;
-    return rv.str();
-}
-
-
-std::string triplet_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    rv << xml_indent() << "<period>" << period << "</period>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void triplet_tinysky::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-        if (extract_xml_record(field,"period",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> period;
-        }
-    }
-}
-
-void triplet_tinysky::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> reserved;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> period;
-    }
-}
-
-void triplet_tinysky::parse(const std::string &s) {
-    SQL_ROW row(&s,17);
-    parse(row);
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+		period=a.period;
+	}
+	return (*this);
+}
+
+
+std::string triplet_tinysky::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<17;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string triplet_tinysky::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
+std::string triplet_tinysky::select_format() const
+{
+std::string rv("");
+for (int i=0; i<16;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string triplet_tinysky::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	rv << ',';
+	rv << period;
+	return rv.str();
+}
+
+
+std::string triplet_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	rv << xml_indent() << "<period>" << period << "</period>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void triplet_tinysky::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	    if (extract_xml_record(field,"period",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> period;
+	      }
+	      }
+	      }
+
+	void triplet_tinysky::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> reserved;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> period;
+	    }
+	      }
+
+	void triplet_tinysky::parse(const std::string &s) {
+	      SQL_ROW row(&s,17);
+	      parse(row);
+	      }
+
 template <> const char * const db_table<autocorr_tinysky>::table_name="autocorr_tinysky";
 template <> const char * db_table<autocorr_tinysky>::_search_tag=table_name;
 template <> const int db_table<autocorr_tinysky>::_nfields=17;
-template <> const char * const db_table<autocorr_tinysky>::column_names[17]= {"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","delay","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
-
-autocorr_tinysky::autocorr_tinysky() :
-    db_table<autocorr_tinysky>(*this,-1),
-    id(0),
-    result_id(),
-    peak_power(0),
-    mean_power(0),
-    time(0),
-    ra(0),
-    decl(0),
-    q_pix(0),
-    delay(0),
-    freq(0),
-    detection_freq(0),
-    barycentric_freq(0),
-    fft_len(0),
-    chirp_rate(0),
-    rfi_checked(0),
-    rfi_found(0),
-    reserved(0) {
-    db_open();
-}
-
-
-autocorr_tinysky::autocorr_tinysky(const autocorr_tinysky &a) :
-    db_table<autocorr_tinysky>(*this,-1),
-    id(a.id),
-    result_id(a.result_id),
-    peak_power(a.peak_power),
-    mean_power(a.mean_power),
-    time(a.time),
-    ra(a.ra),
-    decl(a.decl),
-    q_pix(a.q_pix),
-    delay(a.delay),
-    freq(a.freq),
-    detection_freq(a.detection_freq),
-    barycentric_freq(a.barycentric_freq),
-    fft_len(a.fft_len),
-    chirp_rate(a.chirp_rate),
-    rfi_checked(a.rfi_checked),
-    rfi_found(a.rfi_found),
-    reserved(a.reserved) {
-    db_open();
-}
-
-
-autocorr_tinysky::autocorr_tinysky(const SQL_ROW &a) :
-    db_table<autocorr_tinysky>(*this,-1) {
-    db_open();
-    parse(a);
-}
-
-
-autocorr_tinysky::autocorr_tinysky(const std::string &s,const char *tag) :
-    db_table<autocorr_tinysky>(*this,-1) {
-    db_open();
-    if (xml_match_tag(s,tag)) {
-        parse_xml(s,tag);
-    } else {
-        parse(s);
-    }
+template <> const char * const db_table<autocorr_tinysky>::column_names[17]={"id","result_id","peak_power","mean_power","time","ra","decl","q_pix","delay","freq","detection_freq","barycentric_freq","fft_len","chirp_rate","rfi_checked","rfi_found","reserved"};
+
+autocorr_tinysky::autocorr_tinysky() : 
+	db_table<autocorr_tinysky>(*this,-1),
+	id(0),
+	result_id(),
+	peak_power(0),
+	mean_power(0),
+	time(0),
+	ra(0),
+	decl(0),
+	q_pix(0),
+	delay(0),
+	freq(0),
+	detection_freq(0),
+	barycentric_freq(0),
+	fft_len(0),
+	chirp_rate(0),
+	rfi_checked(0),
+	rfi_found(0),
+	reserved(0)
+{
+	db_open();
+}
+
+
+autocorr_tinysky::autocorr_tinysky(const autocorr_tinysky &a) : 
+	db_table<autocorr_tinysky>(*this,-1),
+	id(a.id),
+	result_id(a.result_id),
+	peak_power(a.peak_power),
+	mean_power(a.mean_power),
+	time(a.time),
+	ra(a.ra),
+	decl(a.decl),
+	q_pix(a.q_pix),
+	delay(a.delay),
+	freq(a.freq),
+	detection_freq(a.detection_freq),
+	barycentric_freq(a.barycentric_freq),
+	fft_len(a.fft_len),
+	chirp_rate(a.chirp_rate),
+	rfi_checked(a.rfi_checked),
+	rfi_found(a.rfi_found),
+	reserved(a.reserved)
+{
+	db_open();
+}
+
+
+autocorr_tinysky::autocorr_tinysky(const SQL_ROW &a) : 
+	db_table<autocorr_tinysky>(*this,-1)
+{
+	db_open();
+	parse(a);
+}
+
+
+autocorr_tinysky::autocorr_tinysky(const std::string &s,const char *tag) : 
+	db_table<autocorr_tinysky>(*this,-1)
+{
+	db_open();
+	if (xml_match_tag(s,tag)) {
+	  parse_xml(s,tag);
+	} else {
+	  parse(s);
+	}
 }
 
 
 autocorr_tinysky &autocorr_tinysky::operator =(const autocorr_tinysky &a) {
-    if (&a != this) {
-        id=a.id;
-        result_id=a.result_id;
-        peak_power=a.peak_power;
-        mean_power=a.mean_power;
-        time=a.time;
-        ra=a.ra;
-        decl=a.decl;
-        q_pix=a.q_pix;
-        delay=a.delay;
-        freq=a.freq;
-        detection_freq=a.detection_freq;
-        barycentric_freq=a.barycentric_freq;
-        fft_len=a.fft_len;
-        chirp_rate=a.chirp_rate;
-        rfi_checked=a.rfi_checked;
-        rfi_found=a.rfi_found;
-        reserved=a.reserved;
-    }
-    return (*this);
-}
-
-
-std::string autocorr_tinysky::update_format() const {
-    std::ostringstream rv("");
-
-    for (int i=2; i<17; i++) rv << "?,";
-    rv << "?";
-    return rv.str();
-}
-
-
-std::string autocorr_tinysky::insert_format() const {
-    return std::string("?,")+update_format();
-}
-
-std::string autocorr_tinysky::select_format() const {
-    std::string rv("");
-    for (int i=0; i<16; i++) rv+="?,";
-    rv+="?";
-    return rv;
-}
-
-std::string autocorr_tinysky::print(int full_subtables, int show_ids, int no_refs) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    if (show_ids) rv << id;
-    rv << ',';
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print(full_subtables,show_ids,no_refs);
-        } else {
-            rv << result_id.id;
-        }
-    }
-    rv << ',';
-    rv << peak_power;
-    rv << ',';
-    rv << mean_power;
-    rv << ',';
-    rv << time;
-    rv << ',';
-    rv << ra;
-    rv << ',';
-    rv << decl;
-    rv << ',';
-    rv << q_pix;
-    rv << ',';
-    rv << delay;
-    rv << ',';
-    rv << freq;
-    rv << ',';
-    rv << detection_freq;
-    rv << ',';
-    rv << barycentric_freq;
-    rv << ',';
-    rv << fft_len;
-    rv << ',';
-    rv << chirp_rate;
-    rv << ',';
-    rv << rfi_checked;
-    rv << ',';
-    rv << rfi_found;
-    rv << ',';
-    rv << reserved;
-    return rv.str();
-}
-
-
-std::string autocorr_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const {
-    std::ostringstream rv("");
-
-    rv.precision(14);
-    rv << xml_indent() << '<' << tag << ">\n";
-    xml_indent(2);
-    if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
-    if (!no_refs) {
-        if (full_subtables) {
-            rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
-        } else {
-            rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
-        }
-    }
-    rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
-    rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
-    rv << xml_indent() << "<time>" << time << "</time>\n";
-    rv << xml_indent() << "<ra>" << ra << "</ra>\n";
-    rv << xml_indent() << "<decl>" << decl << "</decl>\n";
-    rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
-    rv << xml_indent() << "<delay>" << delay << "</delay>\n";
-    rv << xml_indent() << "<freq>" << freq << "</freq>\n";
-    rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
-    rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
-    rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
-    rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
-    rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
-    rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
-    rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
-    xml_indent(-2);
-    rv << xml_indent() << "</" << tag << ">\n";
-    return rv.str();
-}
-
-
-void autocorr_tinysky::parse_xml(const std::string &s,const char *tag) {
-    std::string field,sub;
-    if (extract_xml_record(s,tag,field)) {
-        std::string::size_type pos=0;
-        if (extract_xml_record(field,"id",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> id;
-        }
-        if (extract_xml_record(field,"result_id",sub)) {
-            result_id.parse_xml(sub,"result_id");
-        }
-        if (extract_xml_record(field,"peak_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> peak_power;
-        }
-        if (extract_xml_record(field,"mean_power",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> mean_power;
-        }
-        if (extract_xml_record(field,"time",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> time;
-        }
-        if (extract_xml_record(field,"ra",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> ra;
-        }
-        if (extract_xml_record(field,"decl",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> decl;
-        }
-        if (extract_xml_record(field,"q_pix",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> q_pix;
-        }
-        if (extract_xml_record(field,"delay",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> delay;
-        }
-        if (extract_xml_record(field,"freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> freq;
-        }
-        if (extract_xml_record(field,"detection_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> detection_freq;
-        }
-        if (extract_xml_record(field,"barycentric_freq",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> barycentric_freq;
-        }
-        if (extract_xml_record(field,"fft_len",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> fft_len;
-        }
-        if (extract_xml_record(field,"chirp_rate",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> chirp_rate;
-        }
-        if (extract_xml_record(field,"rfi_checked",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_checked;
-        }
-        if (extract_xml_record(field,"rfi_found",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> rfi_found;
-        }
-        if (extract_xml_record(field,"reserved",sub)) {
-            pos=sub.find(">");
-            do {
-                pos++;
-            } while(sub[pos]=='\n');
-            std::istringstream in(sub.c_str()+pos);
-            in >> reserved;
-        }
-    }
-}
-
-void autocorr_tinysky::parse(const SQL_ROW &s) {
-    {
-        std::istringstream row(*(s[0]));
-        row >> id;
-    }
-    {
-        result_id.parse(SQL_ROW(s[1],0));
-    }
-    {
-        std::istringstream row(*(s[2]));
-        row >> peak_power;
-    }
-    {
-        std::istringstream row(*(s[3]));
-        row >> mean_power;
-    }
-    {
-        std::istringstream row(*(s[4]));
-        row >> time;
-    }
-    {
-        std::istringstream row(*(s[5]));
-        row >> ra;
-    }
-    {
-        std::istringstream row(*(s[6]));
-        row >> decl;
-    }
-    {
-        std::istringstream row(*(s[7]));
-        row >> q_pix;
-    }
-    {
-        std::istringstream row(*(s[8]));
-        row >> delay;
-    }
-    {
-        std::istringstream row(*(s[9]));
-        row >> freq;
-    }
-    {
-        std::istringstream row(*(s[10]));
-        row >> detection_freq;
-    }
-    {
-        std::istringstream row(*(s[11]));
-        row >> barycentric_freq;
-    }
-    {
-        std::istringstream row(*(s[12]));
-        row >> fft_len;
-    }
-    {
-        std::istringstream row(*(s[13]));
-        row >> chirp_rate;
-    }
-    {
-        std::istringstream row(*(s[14]));
-        row >> rfi_checked;
-    }
-    {
-        std::istringstream row(*(s[15]));
-        row >> rfi_found;
-    }
-    {
-        std::istringstream row(*(s[16]));
-        row >> reserved;
-    }
-}
-
-void autocorr_tinysky::parse(const std::string &s) {
-    SQL_ROW row(&s,17);
-    parse(row);
+	if (&a != this) {
+		id=a.id;
+		result_id=a.result_id;
+		peak_power=a.peak_power;
+		mean_power=a.mean_power;
+		time=a.time;
+		ra=a.ra;
+		decl=a.decl;
+		q_pix=a.q_pix;
+		delay=a.delay;
+		freq=a.freq;
+		detection_freq=a.detection_freq;
+		barycentric_freq=a.barycentric_freq;
+		fft_len=a.fft_len;
+		chirp_rate=a.chirp_rate;
+		rfi_checked=a.rfi_checked;
+		rfi_found=a.rfi_found;
+		reserved=a.reserved;
+	}
+	return (*this);
+}
+
+
+std::string autocorr_tinysky::update_format() const
+{	std::ostringstream rv("");
+
+	for (int i=2;i<17;i++) rv << "?,";
+	rv << "?";
+	return rv.str();
+}
+
+
+std::string autocorr_tinysky::insert_format() const
+{	return std::string("?,")+update_format();
 }
 
+std::string autocorr_tinysky::select_format() const
+{
+std::string rv("");
+for (int i=0; i<16;i++) rv+="?,";
+rv+="?";
+return rv;
+}
+
+std::string autocorr_tinysky::print(int full_subtables, int show_ids, int no_refs) const
+{	std::ostringstream rv("");
+
+	rv.precision(14);
+	if (show_ids) rv << id;
+	rv << ',';
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print(full_subtables,show_ids,no_refs);
+	} else {
+	    rv << result_id.id;
+	  }
+	}
+	rv << ',';
+	rv << peak_power;
+	rv << ',';
+	rv << mean_power;
+	rv << ',';
+	rv << time;
+	rv << ',';
+	rv << ra;
+	rv << ',';
+	rv << decl;
+	rv << ',';
+	rv << q_pix;
+	rv << ',';
+	rv << delay;
+	rv << ',';
+	rv << freq;
+	rv << ',';
+	rv << detection_freq;
+	rv << ',';
+	rv << barycentric_freq;
+	rv << ',';
+	rv << fft_len;
+	rv << ',';
+	rv << chirp_rate;
+	rv << ',';
+	rv << rfi_checked;
+	rv << ',';
+	rv << rfi_found;
+	rv << ',';
+	rv << reserved;
+	return rv.str();
+}
+
+
+std::string autocorr_tinysky::print_xml(int full_subtables, int show_ids, int no_refs,const char *tag) const 
+{
+	std::ostringstream rv("");
+
+	rv.precision(14);
+	rv << xml_indent() << '<' << tag << ">\n";
+	xml_indent(2);
+	if (show_ids) rv << xml_indent() << "<id>" << id << "</id>\n";
+	if (!no_refs) {
+	  if (full_subtables) {
+	    rv << result_id.print_xml(full_subtables,show_ids,no_refs,"result_id");
+	} else {
+	    rv << xml_indent() << "<result_id><id>" << result_id.id << "</id></result_id>\n";
+	  }
+	}
+	rv << xml_indent() << "<peak_power>" << peak_power << "</peak_power>\n";
+	rv << xml_indent() << "<mean_power>" << mean_power << "</mean_power>\n";
+	rv << xml_indent() << "<time>" << time << "</time>\n";
+	rv << xml_indent() << "<ra>" << ra << "</ra>\n";
+	rv << xml_indent() << "<decl>" << decl << "</decl>\n";
+	rv << xml_indent() << "<q_pix>" << q_pix << "</q_pix>\n";
+	rv << xml_indent() << "<delay>" << delay << "</delay>\n";
+	rv << xml_indent() << "<freq>" << freq << "</freq>\n";
+	rv << xml_indent() << "<detection_freq>" << detection_freq << "</detection_freq>\n";
+	rv << xml_indent() << "<barycentric_freq>" << barycentric_freq << "</barycentric_freq>\n";
+	rv << xml_indent() << "<fft_len>" << fft_len << "</fft_len>\n";
+	rv << xml_indent() << "<chirp_rate>" << chirp_rate << "</chirp_rate>\n";
+	rv << xml_indent() << "<rfi_checked>" << rfi_checked << "</rfi_checked>\n";
+	rv << xml_indent() << "<rfi_found>" << rfi_found << "</rfi_found>\n";
+	rv << xml_indent() << "<reserved>" << reserved << "</reserved>\n";
+	xml_indent(-2);
+	rv << xml_indent() << "</" << tag << ">\n";
+	return rv.str();
+}
+
+
+	void autocorr_tinysky::parse_xml(const std::string &s,const char *tag) {
+	  std::string field,sub;
+	  if (extract_xml_record(s,tag,field)) {
+	  std::string::size_type pos=0;
+	    if (extract_xml_record(field,"id",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> id;
+	      }
+	    if (extract_xml_record(field,"result_id",sub)) {
+	      result_id.parse_xml(sub,"result_id");
+	    }
+	    if (extract_xml_record(field,"peak_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> peak_power;
+	      }
+	    if (extract_xml_record(field,"mean_power",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> mean_power;
+	      }
+	    if (extract_xml_record(field,"time",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> time;
+	      }
+	    if (extract_xml_record(field,"ra",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> ra;
+	      }
+	    if (extract_xml_record(field,"decl",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> decl;
+	      }
+	    if (extract_xml_record(field,"q_pix",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> q_pix;
+	      }
+	    if (extract_xml_record(field,"delay",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> delay;
+	      }
+	    if (extract_xml_record(field,"freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> freq;
+	      }
+	    if (extract_xml_record(field,"detection_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> detection_freq;
+	      }
+	    if (extract_xml_record(field,"barycentric_freq",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> barycentric_freq;
+	      }
+	    if (extract_xml_record(field,"fft_len",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> fft_len;
+	      }
+	    if (extract_xml_record(field,"chirp_rate",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> chirp_rate;
+	      }
+	    if (extract_xml_record(field,"rfi_checked",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_checked;
+	      }
+	    if (extract_xml_record(field,"rfi_found",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> rfi_found;
+	      }
+	    if (extract_xml_record(field,"reserved",sub)) {
+	        pos=sub.find(">");
+	        do { pos++; } while(sub[pos]=='\n');
+	        std::istringstream in(sub.c_str()+pos);
+	        in >> reserved;
+	      }
+	      }
+	      }
+
+	void autocorr_tinysky::parse(const SQL_ROW &s) {
+	  {  
+	        std::istringstream row(*(s[0]));
+	        row >> id;
+	    }
+	  {  
+	  result_id.parse(SQL_ROW(s[1],0));
+	    }
+	  {  
+	        std::istringstream row(*(s[2]));
+	        row >> peak_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[3]));
+	        row >> mean_power;
+	    }
+	  {  
+	        std::istringstream row(*(s[4]));
+	        row >> time;
+	    }
+	  {  
+	        std::istringstream row(*(s[5]));
+	        row >> ra;
+	    }
+	  {  
+	        std::istringstream row(*(s[6]));
+	        row >> decl;
+	    }
+	  {  
+	        std::istringstream row(*(s[7]));
+	        row >> q_pix;
+	    }
+	  {  
+	        std::istringstream row(*(s[8]));
+	        row >> delay;
+	    }
+	  {  
+	        std::istringstream row(*(s[9]));
+	        row >> freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[10]));
+	        row >> detection_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[11]));
+	        row >> barycentric_freq;
+	    }
+	  {  
+	        std::istringstream row(*(s[12]));
+	        row >> fft_len;
+	    }
+	  {  
+	        std::istringstream row(*(s[13]));
+	        row >> chirp_rate;
+	    }
+	  {  
+	        std::istringstream row(*(s[14]));
+	        row >> rfi_checked;
+	    }
+	  {  
+	        std::istringstream row(*(s[15]));
+	        row >> rfi_found;
+	    }
+	  {  
+	        std::istringstream row(*(s[16]));
+	        row >> reserved;
+	    }
+	      }
+
+	void autocorr_tinysky::parse(const std::string &s) {
+	      SQL_ROW row(&s,17);
+	      parse(row);
+	      }
+
diff --git a/db/schema_master.h b/db/schema_master.h
index 98806fb..252d4f2 100644
--- a/db/schema_master.h
+++ b/db/schema_master.h
@@ -5,1588 +5,1633 @@ extern const char *db_name;
 extern int db_is_open;
 
 #if !defined(CLIENT) && !defined(NEBULA)
-inline int db_open() {
-    if (!db_is_open) db_is_open=sql_database(db_name);
-    return db_is_open;
-}
-inline int db_close() {
-    if (db_is_open) db_is_open=!sql_finish();
-    return !db_is_open;
-}
-inline int db_change(const char *name) {
-    if(strcmp(db_name, name) || !db_is_open) {
-        db_close();
-        db_name=name;
-        db_open();
-    }
-    return(db_is_open);
-}
+inline int db_open() { 
+	  if (!db_is_open) db_is_open=sql_database(db_name);
+	  return db_is_open; }
+inline int db_close() { 
+	  if (db_is_open) db_is_open=!sql_finish();
+	  return !db_is_open; }
+inline int db_change(const char *name) { 
+	 if(strcmp(db_name, name) || !db_is_open) { 
+		  db_close();
+		  db_name=name;
+		  db_open(); } return(db_is_open); }
 #else
-inline int db_open() {
-    return (db_is_open=1);
-}
-inline int db_close() {
-    return !(db_is_open=0);
-}
-inline int db_change() {
-    return (db_is_open=1);
-}
-#endif
+inline int db_open() { return (db_is_open=1); }
+inline int db_close() { return !(db_is_open=0); }
+inline int db_change() { return (db_is_open=1); }
+#ifdef NEBULA
+typedef sqlint8_t long;
+template <typename T, typename ID_TYPE=long> 
+struct db_reference {
+  ID_TYPE id;
+  void parse_xml(std::string &buf, const char *tag) {};
+  void parse(const std::string &buf) {};
+  std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const {};
+  std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=1, const char *tag=0) const {};
+};
+#endif //NEBULA
+
+#endif //CLIENT || NEBULA
 
 class  coordinate_t  : public db_type<coordinate_t> {
-    public:
-        double  time;
-        double  ra;
-        double  dec;
-        coordinate_t();
-        coordinate_t(const coordinate_t &a);
-        coordinate_t(const SQL_ROW &a);
-        coordinate_t(const std::string &s,const char *tag="coordinate_t");
-        coordinate_t &operator =(const coordinate_t &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="coordinate_t") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="coordinate_t");
+  public:
+	double  time;
+	double  ra;
+	double  dec;
+	coordinate_t();
+	coordinate_t(const coordinate_t &a);
+	coordinate_t(const SQL_ROW &a);
+	coordinate_t(const std::string &s,const char *tag="coordinate_t");
+	coordinate_t &operator =(const coordinate_t &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="coordinate_t") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="coordinate_t");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  chirp_parameter_t  : public db_type<chirp_parameter_t> {
-    public:
-        double  chirp_limit;
-        long  fft_len_flags;
-        chirp_parameter_t();
-        chirp_parameter_t(const chirp_parameter_t &a);
-        chirp_parameter_t(const SQL_ROW &a);
-        chirp_parameter_t(const std::string &s,const char *tag="chirp_parameter_t");
-        chirp_parameter_t &operator =(const chirp_parameter_t &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="chirp_parameter_t") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="chirp_parameter_t");
+  public:
+	double  chirp_limit;
+	long  fft_len_flags;
+	chirp_parameter_t();
+	chirp_parameter_t(const chirp_parameter_t &a);
+	chirp_parameter_t(const SQL_ROW &a);
+	chirp_parameter_t(const std::string &s,const char *tag="chirp_parameter_t");
+	chirp_parameter_t &operator =(const chirp_parameter_t &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="chirp_parameter_t") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="chirp_parameter_t");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  subband_description_t  : public db_type<subband_description_t> {
-    public:
-        long  number;
-        double  center;
-        double  base;
-        double  sample_rate;
-        subband_description_t();
-        subband_description_t(const subband_description_t &a);
-        subband_description_t(const SQL_ROW &a);
-        subband_description_t(const std::string &s,const char *tag="subband_description_t");
-        subband_description_t &operator =(const subband_description_t &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="subband_description_t") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="subband_description_t");
+  public:
+	long  number;
+	double  center;
+	double  base;
+	double  sample_rate;
+	subband_description_t();
+	subband_description_t(const subband_description_t &a);
+	subband_description_t(const SQL_ROW &a);
+	subband_description_t(const std::string &s,const char *tag="subband_description_t");
+	subband_description_t &operator =(const subband_description_t &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="subband_description_t") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="subband_description_t");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  data_description_t  : public db_type<data_description_t> {
-    public:
-        double  start_ra;
-        double  start_dec;
-        double  end_ra;
-        double  end_dec;
-        double  true_angle_range;
-        char  time_recorded[255];
-        double  time_recorded_jd;
-        long  nsamples;
-        sqlblob<coordinate_t>  coords ;
-        data_description_t();
-        data_description_t(const data_description_t &a);
-        data_description_t(const SQL_ROW &a);
-        data_description_t(const std::string &s,const char *tag="data_description_t");
-        data_description_t &operator =(const data_description_t &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="data_description_t") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="data_description_t");
+  public:
+	double  start_ra;
+	double  start_dec;
+	double  end_ra;
+	double  end_dec;
+	double  true_angle_range;
+	char  time_recorded[255];
+	double  time_recorded_jd;
+	long  nsamples;
+	sqlblob<coordinate_t>  coords ;
+	data_description_t();
+	data_description_t(const data_description_t &a);
+	data_description_t(const SQL_ROW &a);
+	data_description_t(const std::string &s,const char *tag="data_description_t");
+	data_description_t &operator =(const data_description_t &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="data_description_t") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="data_description_t");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  receiver_config  : public db_table<receiver_config> {
-    public:
-        long  id;
-        long  s4_id;
-        char  name[255];
-        double  beam_width;
-        double  center_freq;
-        double  latitude;
-        double  longitude;
-        double  elevation;
-        double  diameter;
-        double  az_orientation;
-        sqlblob<float>  az_corr_coeff ;
-        sqlblob<float>  zen_corr_coeff ;
-        double  array_az_ellipse;
-        double  array_za_ellipse;
-        double  array_angle;
-        long  min_vgc;
-        receiver_config();
-        receiver_config(const receiver_config &a);
-        receiver_config(const SQL_ROW &a);
-        receiver_config(const std::string &s,const char *tag="receiver_config");
-        receiver_config &operator =(const receiver_config &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="receiver_config") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="receiver_config");
+  public:
+	long  id;
+	long  s4_id;
+	char  name[255];
+	double  beam_width;
+	double  center_freq;
+	double  latitude;
+	double  longitude;
+	double  elevation;
+	double  diameter;
+	double  az_orientation;
+	sqlblob<float>  az_corr_coeff ;
+	sqlblob<float>  zen_corr_coeff ;
+	double  array_az_ellipse;
+	double  array_za_ellipse;
+	double  array_angle;
+	long  min_vgc;
+	receiver_config();
+	receiver_config(const receiver_config &a);
+	receiver_config(const SQL_ROW &a);
+	receiver_config(const std::string &s,const char *tag="receiver_config");
+	receiver_config &operator =(const receiver_config &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="receiver_config") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="receiver_config");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  recorder_config  : public db_table<recorder_config> {
-    public:
-        long  id;
-        char  name[64];
-        long  bits_per_sample;
-        double  sample_rate;
-        long  beams;
-        double  version;
-        recorder_config();
-        recorder_config(const recorder_config &a);
-        recorder_config(const SQL_ROW &a);
-        recorder_config(const std::string &s,const char *tag="recorder_config");
-        recorder_config &operator =(const recorder_config &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="recorder_config") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="recorder_config");
+  public:
+	long  id;
+	char  name[64];
+	long  bits_per_sample;
+	double  sample_rate;
+	long  beams;
+	double  version;
+	recorder_config();
+	recorder_config(const recorder_config &a);
+	recorder_config(const SQL_ROW &a);
+	recorder_config(const std::string &s,const char *tag="recorder_config");
+	recorder_config &operator =(const recorder_config &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="recorder_config") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="recorder_config");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  splitter_config  : public db_table<splitter_config> {
-    public:
-        long  id;
-        double  version;
-        char  data_type[64];
-        long  fft_len;
-        long  ifft_len;
-        char  filter[64];
-        char  window[64];
-        long  samples_per_wu;
-        double  highpass;
-        char  blanker_filter[64];
-        long  pfb_ntaps;
-        double  pfb_width_factor;
-        splitter_config();
-        splitter_config(const splitter_config &a);
-        splitter_config(const SQL_ROW &a);
-        splitter_config(const std::string &s,const char *tag="splitter_config");
-        splitter_config &operator =(const splitter_config &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="splitter_config") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="splitter_config");
+  public:
+	long  id;
+	double  version;
+	char  data_type[64];
+	long  fft_len;
+	long  ifft_len;
+	char  filter[64];
+	char  window[64];
+	long  samples_per_wu;
+	double  highpass;
+	char  blanker_filter[64];
+	long  pfb_ntaps;
+	double  pfb_width_factor;
+	long  wu_bits_per_sample;
+	splitter_config();
+	splitter_config(const splitter_config &a);
+	splitter_config(const SQL_ROW &a);
+	splitter_config(const std::string &s,const char *tag="splitter_config");
+	splitter_config &operator =(const splitter_config &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="splitter_config") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="splitter_config");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  analysis_config  : public db_table<analysis_config> {
-    public:
-        long  id;
-        double  spike_thresh;
-        long  spikes_per_spectrum;
-        double  autocorr_thresh;
-        long  autocorr_per_spectrum;
-        long  autocorr_fftlen;
-        double  gauss_null_chi_sq_thresh;
-        double  gauss_chi_sq_thresh;
-        double  gauss_power_thresh;
-        double  gauss_peak_power_thresh;
-        long  gauss_pot_length;
-        double  pulse_thresh;
-        double  pulse_display_thresh;
-        long  pulse_max;
-        long  pulse_min;
-        long  pulse_fft_max;
-        long  pulse_pot_length;
-        double  triplet_thresh;
-        long  triplet_max;
-        long  triplet_min;
-        long  triplet_pot_length;
-        double  pot_overlap_factor;
-        double  pot_t_offset;
-        double  pot_min_slew;
-        double  pot_max_slew;
-        double  chirp_resolution;
-        long  analysis_fft_lengths;
-        long  bsmooth_boxcar_length;
-        long  bsmooth_chunk_size;
-        sqlblob<chirp_parameter_t>  chirps ;
-        double  pulse_beams;
-        long  max_signals;
-        long  max_spikes;
-        long  max_autocorr;
-        long  max_gaussians;
-        long  max_pulses;
-        long  max_triplets;
-        long  keyuniq;
-        double  credit_rate;
-        analysis_config();
-        analysis_config(const analysis_config &a);
-        analysis_config(const SQL_ROW &a);
-        analysis_config(const std::string &s,const char *tag="analysis_config");
-        analysis_config &operator =(const analysis_config &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="analysis_config") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="analysis_config");
+  public:
+	long  id;
+	double  spike_thresh;
+	long  spikes_per_spectrum;
+	double  autocorr_thresh;
+	long  autocorr_per_spectrum;
+	long  autocorr_fftlen;
+	double  gauss_null_chi_sq_thresh;
+	double  gauss_chi_sq_thresh;
+	double  gauss_power_thresh;
+	double  gauss_peak_power_thresh;
+	long  gauss_pot_length;
+	double  pulse_thresh;
+	double  pulse_display_thresh;
+	long  pulse_max;
+	long  pulse_min;
+	long  pulse_fft_max;
+	long  pulse_pot_length;
+	double  triplet_thresh;
+	long  triplet_max;
+	long  triplet_min;
+	long  triplet_pot_length;
+	double  pot_overlap_factor;
+	double  pot_t_offset;
+	double  pot_min_slew;
+	double  pot_max_slew;
+	double  chirp_resolution;
+	long  analysis_fft_lengths;
+	long  bsmooth_boxcar_length;
+	long  bsmooth_chunk_size;
+	sqlblob<chirp_parameter_t>  chirps ;
+	double  pulse_beams;
+	long  max_signals;
+	long  max_spikes;
+	long  max_autocorr;
+	long  max_gaussians;
+	long  max_pulses;
+	long  max_triplets;
+	long  keyuniq;
+	double  credit_rate;
+	analysis_config();
+	analysis_config(const analysis_config &a);
+	analysis_config(const SQL_ROW &a);
+	analysis_config(const std::string &s,const char *tag="analysis_config");
+	analysis_config &operator =(const analysis_config &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="analysis_config") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="analysis_config");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  science_config  : public db_table<science_config> {
-    public:
-        long  id;
-        long  active;
-        char  qpix_scheme[16];
-        long  qpix_nside;
-        double  fpix_width;
-        double  total_bandwidth;
-        double  freq_uncertainty;
-        double  fwhm_beamwidth;
-        double  sky_disc_radius;
-        double  observable_sky;
-        long  epoch;
-        double  bary_chirp_window;
-        long  bary_freq_window;
-        long  nonbary_freq_window;
-        double  spike_obs_duration;
-        double  spike_obs_interval;
-        double  gauss_obs_duration;
-        double  gauss_obs_interval;
-        double  pulse_obs_duration;
-        double  pulse_obs_interval;
-        double  triplet_obs_duration;
-        double  triplet_obs_interval;
-        sqlint8_t  min_spike_id;
-        sqlint8_t  min_autocorr_id;
-        sqlint8_t  min_gaussian_id;
-        sqlint8_t  min_pulse_id;
-        sqlint8_t  min_triplet_id;
-        double  min_app_version;
-        char  info_xml[255];
-        science_config();
-        science_config(const science_config &a);
-        science_config(const SQL_ROW &a);
-        science_config(const std::string &s,const char *tag="science_config");
-        science_config &operator =(const science_config &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="science_config") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="science_config");
+  public:
+	long  id;
+	long  active;
+	char  qpix_scheme[16];
+	long  qpix_nside;
+	double  fpix_width;
+	double  total_bandwidth;
+	double  freq_uncertainty;
+	double  fwhm_beamwidth;
+	double  sky_disc_radius;
+	double  observable_sky;
+	long  epoch;
+	double  bary_chirp_window;
+	long  bary_freq_window;
+	long  nonbary_freq_window;
+	double  spike_obs_duration;
+	double  spike_obs_interval;
+	double  gauss_obs_duration;
+	double  gauss_obs_interval;
+	double  pulse_obs_duration;
+	double  pulse_obs_interval;
+	double  triplet_obs_duration;
+	double  triplet_obs_interval;
+	sqlint8_t  min_spike_id;
+	sqlint8_t  min_autocorr_id;
+	sqlint8_t  min_gaussian_id;
+	sqlint8_t  min_pulse_id;
+	sqlint8_t  min_triplet_id;
+	double  min_app_version;
+	char  info_xml[255];
+	science_config();
+	science_config(const science_config &a);
+	science_config(const SQL_ROW &a);
+	science_config(const std::string &s,const char *tag="science_config");
+	science_config &operator =(const science_config &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="science_config") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="science_config");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  candidate_t  : public db_type<candidate_t> {
-    public:
-        long  type;
-        sqlint8_t  id;
-        long  num_obs;
-        double  score;
-        long  is_rfi;
-        candidate_t();
-        candidate_t(const candidate_t &a);
-        candidate_t(const SQL_ROW &a);
-        candidate_t(const std::string &s,const char *tag="candidate_t");
-        candidate_t &operator =(const candidate_t &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="candidate_t") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="candidate_t");
+  public:
+	long  type;
+	sqlint8_t  id;
+	long  num_obs;
+	double  score;
+	long  is_rfi;
+	candidate_t();
+	candidate_t(const candidate_t &a);
+	candidate_t(const SQL_ROW &a);
+	candidate_t(const std::string &s,const char *tag="candidate_t");
+	candidate_t &operator =(const candidate_t &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="candidate_t") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="candidate_t");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  meta_candidate  : public db_table<meta_candidate> {
-    public:
-        sqlint8_t  id;
-        long  version;
-        double  time_last_updated;
-        long  num_spikes;
-        long  num_spike_b_multiplets;
-        double  best_spike_b_mp_score;
-        long  num_spike_nb_multiplets;
-        double  best_spike_nb_mp_score;
-        sqlint8_t  spike_high_id;
-        long  num_gaussians;
-        long  num_gaussian_b_multiplets;
-        double  best_gaussian_b_mp_score;
-        long  num_gaussian_nb_multiplets;
-        double  best_gaussian_nb_mp_score;
-        sqlint8_t  gaussian_high_id;
-        long  num_pulses;
-        long  num_pulse_b_multiplets;
-        double  best_pulse_b_mp_score;
-        long  num_pulse_nb_multiplets;
-        double  best_pulse_nb_mp_score;
-        sqlint8_t  pulse_high_id;
-        long  num_triplets;
-        long  num_triplet_b_multiplets;
-        double  best_triplet_b_mp_score;
-        long  num_triplet_nb_multiplets;
-        double  best_triplet_nb_mp_score;
-        sqlint8_t  triplet_high_id;
-        long  num_stars;
-        double  best_star_score;
-        double  meta_score;
-        long  rfi_clean;
-        long  state;
-        meta_candidate();
-        meta_candidate(const meta_candidate &a);
-        meta_candidate(const SQL_ROW &a);
-        meta_candidate(const std::string &s,const char *tag="meta_candidate");
-        meta_candidate &operator =(const meta_candidate &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="meta_candidate") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="meta_candidate");
+  public:
+	sqlint8_t  id;
+	long  version;
+	double  time_last_updated;
+	long  num_spikes;
+	long  num_spike_b_multiplets;
+	double  best_spike_b_mp_score;
+	long  num_spike_nb_multiplets;
+	double  best_spike_nb_mp_score;
+	sqlint8_t  spike_high_id;
+	long  num_gaussians;
+	long  num_gaussian_b_multiplets;
+	double  best_gaussian_b_mp_score;
+	long  num_gaussian_nb_multiplets;
+	double  best_gaussian_nb_mp_score;
+	sqlint8_t  gaussian_high_id;
+	long  num_pulses;
+	long  num_pulse_b_multiplets;
+	double  best_pulse_b_mp_score;
+	long  num_pulse_nb_multiplets;
+	double  best_pulse_nb_mp_score;
+	sqlint8_t  pulse_high_id;
+	long  num_triplets;
+	long  num_triplet_b_multiplets;
+	double  best_triplet_b_mp_score;
+	long  num_triplet_nb_multiplets;
+	double  best_triplet_nb_mp_score;
+	sqlint8_t  triplet_high_id;
+	long  num_stars;
+	double  best_star_score;
+	double  meta_score;
+	long  rfi_clean;
+	long  state;
+	meta_candidate();
+	meta_candidate(const meta_candidate &a);
+	meta_candidate(const SQL_ROW &a);
+	meta_candidate(const std::string &s,const char *tag="meta_candidate");
+	meta_candidate &operator =(const meta_candidate &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="meta_candidate") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="meta_candidate");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
-class  multiplet  : public db_table<multiplet> {
-    public:
-        long  id;
-        long  version;
-        long  signal_type;
-        long  mp_type;
-        long  qpix;
-        double  freq_win;
-        double  mean_ra;
-        double  mean_decl;
-        double  ra_stddev;
-        double  decl_stddev;
-        double  mean_angular_distance;
-        double  angular_distance_stddev;
-        double  mean_frequency;
-        double  frequency_stddev;
-        double  mean_chirp;
-        double  chirp_stddev;
-        double  mean_period;
-        double  period_stddev;
-        double  mean_snr;
-        double  snr_stddev;
-        double  mean_threshold;
-        double  threshold_stddev;
-        double  score;
-        long  num_detections;
+
+class  meta_candidate_tinysky  : public db_table<meta_candidate_tinysky> {
+  public:
+	sqlint8_t  id;
+	long  version;
+	double  time_last_updated;
+	long  num_spikes;
+	long  num_spike_b_multiplets;
+	double  best_spike_b_mp_score;
+	long  num_spike_nb_multiplets;
+	double  best_spike_nb_mp_score;
+	sqlint8_t  spike_high_id;
+	long  num_gaussians;
+	long  num_gaussian_b_multiplets;
+	double  best_gaussian_b_mp_score;
+	long  num_gaussian_nb_multiplets;
+	double  best_gaussian_nb_mp_score;
+	sqlint8_t  gaussian_high_id;
+	long  num_pulses;
+	long  num_pulse_b_multiplets;
+	double  best_pulse_b_mp_score;
+	long  num_pulse_nb_multiplets;
+	double  best_pulse_nb_mp_score;
+	sqlint8_t  pulse_high_id;
+	long  num_triplets;
+	long  num_triplet_b_multiplets;
+	double  best_triplet_b_mp_score;
+	long  num_triplet_nb_multiplets;
+	double  best_triplet_nb_mp_score;
+	sqlint8_t  triplet_high_id;
+	long  num_stars;
+	double  best_star_score;
+	double  meta_score;
+	long  rfi_clean;
+	long  state;
+	meta_candidate_tinysky();
+	meta_candidate_tinysky(const meta_candidate_tinysky &a);
+	meta_candidate_tinysky(const SQL_ROW &a);
+	meta_candidate_tinysky(const std::string &s,const char *tag="meta_candidate_tinysky");
+	meta_candidate_tinysky &operator =(const meta_candidate_tinysky &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="meta_candidate_tinysky") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="meta_candidate_tinysky");
 #ifdef NEBULA
-        std::vector<long> signal_ids;
-#else
-        sqlblob<sqlint8_t>  signal_ids ;
+	bool nebula_read(FILE *f);
 #endif
-        multiplet();
-        multiplet(const multiplet &a);
-        multiplet(const SQL_ROW &a);
-        multiplet(const std::string &s,const char *tag="multiplet");
-        multiplet &operator =(const multiplet &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="multiplet") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="multiplet");
+  private:
+};
+
+
+class  multiplet  : public db_table<multiplet> {
+  public:
+	long  id;
+	long  version;
+	long  signal_type;
+	long  mp_type;
+	long  qpix;
+	double  freq_win;
+	double  mean_ra;
+	double  mean_decl;
+	double  ra_stddev;
+	double  decl_stddev;
+	double  mean_angular_distance;
+	double  angular_distance_stddev;
+	double  mean_frequency;
+	double  frequency_stddev;
+	double  mean_chirp;
+	double  chirp_stddev;
+	double  mean_period;
+	double  period_stddev;
+	double  mean_snr;
+	double  snr_stddev;
+	double  mean_threshold;
+	double  threshold_stddev;
+	double  score;
+	long  num_detections;
+	sqlblob<sqlint8_t>  signal_ids ;
+	multiplet();
+	multiplet(const multiplet &a);
+	multiplet(const SQL_ROW &a);
+	multiplet(const std::string &s,const char *tag="multiplet");
+	multiplet &operator =(const multiplet &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="multiplet") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="multiplet");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  star  : public db_table<star> {
-    public:
-        long  id;
-        char  object_type[16];
-        char  catalog_name[64];
-        long  catalog_number;
-        char  object_name[64];
-        double  ra;
-        double  decl;
-        long  qpix;
-        double  v_mag;
-        double  b_minus_v;
-        double  parallax;
-        char  stellar_type[32];
-        long  planets;
-        double  score;
-        star();
-        star(const star &a);
-        star(const SQL_ROW &a);
-        star(const std::string &s,const char *tag="star");
-        star &operator =(const star &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="star") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="star");
+  public:
+	long  id;
+	char  object_type[16];
+	char  catalog_name[64];
+	long  catalog_number;
+	char  object_name[64];
+	double  ra;
+	double  decl;
+	long  qpix;
+	double  v_mag;
+	double  b_minus_v;
+	double  parallax;
+	char  stellar_type[32];
+	long  planets;
+	double  score;
+	star();
+	star(const star &a);
+	star(const SQL_ROW &a);
+	star(const std::string &s,const char *tag="star");
+	star &operator =(const star &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="star") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="star");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  candidate_count  : public db_table<candidate_count> {
-    public:
-        long  id;
-        sqlint8_t  spikes;
-        sqlint8_t  gaussians;
-        sqlint8_t  pulses;
-        sqlint8_t  triplets;
-        sqlint8_t  spike_barycentric_multiplets;
-        sqlint8_t  gaussian_barycentric_multiplets;
-        sqlint8_t  pulse_barycentric_multiplets;
-        sqlint8_t  triplet_barycentric_multiplets;
-        sqlint8_t  spike_nonbarycentric_multiplets;
-        sqlint8_t  gaussian_nonbarycentric_multiplets;
-        sqlint8_t  pulse_nonbarycentric_multiplets;
-        sqlint8_t  triplet_nonbarycentric_multiplets;
-        sqlint8_t  stars;
-        long  time_last_updated;
-        candidate_count();
-        candidate_count(const candidate_count &a);
-        candidate_count(const SQL_ROW &a);
-        candidate_count(const std::string &s,const char *tag="candidate_count");
-        candidate_count &operator =(const candidate_count &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="candidate_count") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="candidate_count");
+  public:
+	long  id;
+	sqlint8_t  spikes;
+	sqlint8_t  gaussians;
+	sqlint8_t  pulses;
+	sqlint8_t  triplets;
+	sqlint8_t  spike_barycentric_multiplets;
+	sqlint8_t  gaussian_barycentric_multiplets;
+	sqlint8_t  pulse_barycentric_multiplets;
+	sqlint8_t  triplet_barycentric_multiplets;
+	sqlint8_t  spike_nonbarycentric_multiplets;
+	sqlint8_t  gaussian_nonbarycentric_multiplets;
+	sqlint8_t  pulse_nonbarycentric_multiplets;
+	sqlint8_t  triplet_nonbarycentric_multiplets;
+	sqlint8_t  stars;
+	long  time_last_updated;
+	candidate_count();
+	candidate_count(const candidate_count &a);
+	candidate_count(const SQL_ROW &a);
+	candidate_count(const std::string &s,const char *tag="candidate_count");
+	candidate_count &operator =(const candidate_count &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="candidate_count") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="candidate_count");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  tape  : public db_table<tape> {
-    public:
-        long  id;
-        char  name[20];
-        double  start_time;
-        double  last_block_time;
-        long  last_block_done;
-        long  missed;
-        long  tape_quality;
-        long  beam;
-        tape();
-        tape(const tape &a);
-        tape(const SQL_ROW &a);
-        tape(const std::string &s,const char *tag="tape");
-        tape &operator =(const tape &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="tape") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="tape");
+  public:
+	long  id;
+	char  name[128];
+	double  start_time;
+	double  last_block_time;
+	long  last_block_done;
+	long  missed;
+	long  tape_quality;
+	long  beam;
+	tape();
+	tape(const tape &a);
+	tape(const SQL_ROW &a);
+	tape(const std::string &s,const char *tag="tape");
+	tape &operator =(const tape &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="tape") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="tape");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  settings  : public db_table<settings> {
-    public:
-        long  id;
-        long  active;
-        db_reference<recorder_config,long> recorder_cfg;
-        db_reference<splitter_config,long> splitter_cfg;
-        db_reference<analysis_config,long> analysis_cfg;
-        db_reference<receiver_config,long> receiver_cfg;
-        settings();
-        settings(const settings &a);
-        settings(const SQL_ROW &a);
-        settings(const std::string &s,const char *tag="settings");
-        settings &operator =(const settings &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="settings") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="settings");
+  public:
+	long  id;
+	long  active;
+	db_reference<recorder_config,long> recorder_cfg;
+	db_reference<splitter_config,long> splitter_cfg;
+	db_reference<analysis_config,long> analysis_cfg;
+	db_reference<receiver_config,long> receiver_cfg;
+	settings();
+	settings(const settings &a);
+	settings(const SQL_ROW &a);
+	settings(const std::string &s,const char *tag="settings");
+	settings &operator =(const settings &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="settings") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="settings");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  workunit_grp  : public db_table<workunit_grp> {
-    public:
-        long  id;
-        db_reference<tape,long> tape_info;
-        char  name[64];
-        data_description_t data_desc;
-        db_reference<receiver_config,long> receiver_cfg;
-        db_reference<recorder_config,long> recorder_cfg;
-        db_reference<splitter_config,long> splitter_cfg;
-        db_reference<analysis_config,long> analysis_cfg;
-        long  sb_id;
-        long  iq_modified;
-        long  alfa_filter_bank;
-        workunit_grp();
-        workunit_grp(const workunit_grp &a);
-        workunit_grp(const SQL_ROW &a);
-        workunit_grp(const std::string &s,const char *tag="workunit_grp");
-        workunit_grp &operator =(const workunit_grp &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="workunit_grp") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="workunit_grp");
+  public:
+	long  id;
+	db_reference<tape,long> tape_info;
+	char  name[128];
+	data_description_t data_desc;
+	db_reference<receiver_config,long> receiver_cfg;
+	db_reference<recorder_config,long> recorder_cfg;
+	db_reference<splitter_config,long> splitter_cfg;
+	db_reference<analysis_config,long> analysis_cfg;
+	long  sb_id;
+	long  iq_modified;
+	long  alfa_filter_bank;
+	workunit_grp();
+	workunit_grp(const workunit_grp &a);
+	workunit_grp(const SQL_ROW &a);
+	workunit_grp(const std::string &s,const char *tag="workunit_grp");
+	workunit_grp &operator =(const workunit_grp &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="workunit_grp") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="workunit_grp");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  workunit_header  : public db_table<workunit_header> {
-    public:
-        sqlint8_t  id;
-        char  name[64];
-        db_reference<workunit_grp,long> group_info;
-        subband_description_t subband_desc;
-        sqlint8_t  sb_id;
-        workunit_header();
-        workunit_header(const workunit_header &a);
-        workunit_header(const SQL_ROW &a);
-        workunit_header(const std::string &s,const char *tag="workunit_header");
-        workunit_header &operator =(const workunit_header &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="workunit_header") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="workunit_header");
+  public:
+	sqlint8_t  id;
+	char  name[128];
+	db_reference<workunit_grp,long> group_info;
+	subband_description_t subband_desc;
+	sqlint8_t  sb_id;
+	workunit_header();
+	workunit_header(const workunit_header &a);
+	workunit_header(const SQL_ROW &a);
+	workunit_header(const std::string &s,const char *tag="workunit_header");
+	workunit_header &operator =(const workunit_header &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="workunit_header") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="workunit_header");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 typedef workunit_header workunit;
 class  result  : public db_table<result> {
-    public:
-        sqlint8_t  id;
-        sqlint8_t  boinc_result;
-        db_reference<workunit_header,sqlint8_t> wuid;
-        double  received;
-        long  hostid;
-        long  versionid;
-        long  return_code;
-        long  overflow;
-        long  reserved;
-        sqlint8_t  sb_id;
-        result();
-        result(const result &a);
-        result(const SQL_ROW &a);
-        result(const std::string &s,const char *tag="result");
-        result &operator =(const result &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="result") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="result");
+  public:
+	sqlint8_t  id;
+	sqlint8_t  boinc_result;
+	db_reference<workunit_header,sqlint8_t> wuid;
+	double  received;
+	long  hostid;
+	long  versionid;
+	long  return_code;
+	long  overflow;
+	long  reserved;
+	sqlint8_t  sb_id;
+	result();
+	result(const result &a);
+	result(const SQL_ROW &a);
+	result(const std::string &s,const char *tag="result");
+	result &operator =(const result &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="result") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="result");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
-struct DB_REF {
-    long id;
-    void parse_xml(std::string &buf, const char *tag){}
-    void parse(const std::string &buf){}
-    void parse(const SQL_ROW &buf){}
-    std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const{}
-    std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=1, const char *tag=0) const{}
-};
 
 class  triplet  : public db_table<triplet> {
-    public:
-        sqlint8_t  id;
-#ifdef NEBULA
-        DB_REF result_id;
-#else
-        db_reference<result,sqlint8_t> result_id;
-#endif
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        double  period;
-        triplet();
-        triplet(const triplet &a);
-        triplet(const SQL_ROW &a);
-        triplet(const std::string &s,const char *tag="triplet");
-        triplet &operator =(const triplet &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="triplet") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="triplet");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	double  period;
+	triplet();
+	triplet(const triplet &a);
+	triplet(const SQL_ROW &a);
+	triplet(const std::string &s,const char *tag="triplet");
+	triplet &operator =(const triplet &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="triplet") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="triplet");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  triplet_small  : public db_table<triplet_small> {
-    public:
-        sqlint8_t  id;
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	double  period;
+	triplet_small();
+	triplet_small(const triplet_small &a);
+	triplet_small(const SQL_ROW &a);
+	triplet_small(const std::string &s,const char *tag="triplet_small");
+	triplet_small &operator =(const triplet_small &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="triplet_small") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="triplet_small");
 #ifdef NEBULA
-        DB_REF result_id;
-#else
-        db_reference<result,sqlint8_t> result_id;
+	bool nebula_read(FILE *f);
 #endif
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        double  period;
-        triplet_small();
-        triplet_small(const triplet_small &a);
-        triplet_small(const SQL_ROW &a);
-        triplet_small(const std::string &s,const char *tag="triplet_small");
-        triplet_small &operator =(const triplet_small &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="triplet_small") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="triplet_small");
-#ifdef NEBULA
-        bool nebula_read(FILE *f);
-#endif
-    private:
+  private:
 };
 
 
 class  gaussian  : public db_table<gaussian> {
-    public:
-        sqlint8_t  id;
-#ifdef NEBULA
-        DB_REF result_id;
-#else
-        db_reference<result,sqlint8_t> result_id;
-#endif
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        double  sigma;
-        double  chisqr;
-        double  null_chisqr;
-        double  score;
-        double  max_power;
-        sqlblob<unsigned char>  pot;
-        gaussian();
-        gaussian(const gaussian &a);
-        gaussian(const SQL_ROW &a);
-        gaussian(const std::string &s,const char *tag="gaussian");
-        gaussian &operator =(const gaussian &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="gaussian") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="gaussian");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	double  sigma;
+	double  chisqr;
+	double  null_chisqr;
+	double  score;
+	double  max_power;
+	sqlblob<unsigned char>  pot;
+	gaussian();
+	gaussian(const gaussian &a);
+	gaussian(const SQL_ROW &a);
+	gaussian(const std::string &s,const char *tag="gaussian");
+	gaussian &operator =(const gaussian &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="gaussian") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="gaussian");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  gaussian_small  : public db_table<gaussian_small> {
-    public:
-        sqlint8_t  id;
-        db_reference<result,sqlint8_t> result_id;
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        double  sigma;
-        double  chisqr;
-        double  null_chisqr;
-        double  score;
-        double  max_power;
-        gaussian_small();
-        gaussian_small(const gaussian_small &a);
-        gaussian_small(const SQL_ROW &a);
-        gaussian_small(const std::string &s,const char *tag="gaussian_small");
-        gaussian_small &operator =(const gaussian_small &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="gaussian_small") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="gaussian_small");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	double  sigma;
+	double  chisqr;
+	double  null_chisqr;
+	double  score;
+	double  max_power;
+	gaussian_small();
+	gaussian_small(const gaussian_small &a);
+	gaussian_small(const SQL_ROW &a);
+	gaussian_small(const std::string &s,const char *tag="gaussian_small");
+	gaussian_small &operator =(const gaussian_small &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="gaussian_small") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="gaussian_small");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  pulse  : public db_table<pulse> {
-    public:
-        sqlint8_t  id;
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	double  period;
+	double  snr;
+	double  thresh;
+	double  score;
+	long  len_prof;
+	sqlblob<unsigned char>  pot;
+	pulse();
+	pulse(const pulse &a);
+	pulse(const SQL_ROW &a);
+	pulse(const std::string &s,const char *tag="pulse");
+	pulse &operator =(const pulse &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="pulse") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="pulse");
 #ifdef NEBULA
-        DB_REF result_id;
-#else
-        db_reference<result,sqlint8_t> result_id;
-#endif
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        double  period;
-        double  snr;
-        double  thresh;
-        double  score;
-        long  len_prof;
-        sqlblob<unsigned char>  pot;
-        pulse();
-        pulse(const pulse &a);
-        pulse(const SQL_ROW &a);
-        pulse(const std::string &s,const char *tag="pulse");
-        pulse &operator =(const pulse &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="pulse") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="pulse");
-#ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  pulse_small  : public db_table<pulse_small> {
-    public:
-        sqlint8_t  id;
-        db_reference<result,sqlint8_t> result_id;
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        double  period;
-        double  snr;
-        double  thresh;
-        double  score;
-        pulse_small();
-        pulse_small(const pulse_small &a);
-        pulse_small(const SQL_ROW &a);
-        pulse_small(const std::string &s,const char *tag="pulse_small");
-        pulse_small &operator =(const pulse_small &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="pulse_small") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="pulse_small");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	double  period;
+	double  snr;
+	double  thresh;
+	double  score;
+	pulse_small();
+	pulse_small(const pulse_small &a);
+	pulse_small(const SQL_ROW &a);
+	pulse_small(const std::string &s,const char *tag="pulse_small");
+	pulse_small &operator =(const pulse_small &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="pulse_small") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="pulse_small");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  sah_pointing  : public db_table<sah_pointing> {
-    public:
-        long  time_id;
-        double  time;
-        double  ra;
-        double  dec;
-        long  q_pix;
-        double  angle_range;
-        long  bad;
-        sah_pointing();
-        sah_pointing(const sah_pointing &a);
-        sah_pointing(const SQL_ROW &a);
-        sah_pointing(const std::string &s,const char *tag="sah_pointing");
-        sah_pointing &operator =(const sah_pointing &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="sah_pointing") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="sah_pointing");
+  public:
+	long  time_id;
+	double  time;
+	double  ra;
+	double  dec;
+	long  q_pix;
+	double  angle_range;
+	long  bad;
+	sah_pointing();
+	sah_pointing(const sah_pointing &a);
+	sah_pointing(const SQL_ROW &a);
+	sah_pointing(const std::string &s,const char *tag="sah_pointing");
+	sah_pointing &operator =(const sah_pointing &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="sah_pointing") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="sah_pointing");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  sky_map  : public db_table<sky_map> {
-    public:
-        sqlint8_t  npix;
-        long  qpix;
-        long  fpix;
-        sqlint8_t  spike_max_id;
-        sqlint8_t  gaussian_max_id;
-        sqlint8_t  pulse_max_id;
-        sqlint8_t  triplet_max_id;
-        long  spike_count;
-        long  gaussian_count;
-        long  pulse_count;
-        long  triplet_count;
-        long  new_data;
-        double  score;
-        sky_map();
-        sky_map(const sky_map &a);
-        sky_map(const SQL_ROW &a);
-        sky_map(const std::string &s,const char *tag="sky_map");
-        sky_map &operator =(const sky_map &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="sky_map") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="sky_map");
+  public:
+	sqlint8_t  npix;
+	long  qpix;
+	long  fpix;
+	sqlint8_t  spike_max_id;
+	sqlint8_t  gaussian_max_id;
+	sqlint8_t  pulse_max_id;
+	sqlint8_t  triplet_max_id;
+	long  spike_count;
+	long  gaussian_count;
+	long  pulse_count;
+	long  triplet_count;
+	long  new_data;
+	double  score;
+	sky_map();
+	sky_map(const sky_map &a);
+	sky_map(const SQL_ROW &a);
+	sky_map(const std::string &s,const char *tag="sky_map");
+	sky_map &operator =(const sky_map &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="sky_map") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="sky_map");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  hotpix  : public db_table<hotpix> {
-    public:
-        long  id;
-        long  last_hit_time;
-        hotpix();
-        hotpix(const hotpix &a);
-        hotpix(const SQL_ROW &a);
-        hotpix(const std::string &s,const char *tag="hotpix");
-        hotpix &operator =(const hotpix &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="hotpix") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="hotpix");
+  public:
+	long  id;
+	long  last_hit_time;
+	hotpix();
+	hotpix(const hotpix &a);
+	hotpix(const SQL_ROW &a);
+	hotpix(const std::string &s,const char *tag="hotpix");
+	hotpix &operator =(const hotpix &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="hotpix") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="hotpix");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
-class  spike  : public db_table<spike> {
-    public:
-        sqlint8_t  id;
+class  hotpix_tinysky  : public db_table<hotpix_tinysky> {
+  public:
+	long  id;
+	long  last_hit_time;
+	hotpix_tinysky();
+	hotpix_tinysky(const hotpix_tinysky &a);
+	hotpix_tinysky(const SQL_ROW &a);
+	hotpix_tinysky(const std::string &s,const char *tag="hotpix_tinysky");
+	hotpix_tinysky &operator =(const hotpix_tinysky &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="hotpix_tinysky") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="hotpix_tinysky");
 #ifdef NEBULA
-        DB_REF result_id;
-#else
-        db_reference<result,sqlint8_t> result_id;
+	bool nebula_read(FILE *f);
 #endif
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        spike();
-        spike(const spike &a);
-        spike(const SQL_ROW &a);
-        spike(const std::string &s,const char *tag="spike");
-        spike &operator =(const spike &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="spike") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="spike");
+  private:
+};
+
+
+class  spike  : public db_table<spike> {
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	spike();
+	spike(const spike &a);
+	spike(const SQL_ROW &a);
+	spike(const std::string &s,const char *tag="spike");
+	spike &operator =(const spike &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="spike") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="spike");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  spike_small  : public db_table<spike_small> {
-    public:
-        sqlint8_t  id;
-        db_reference<result,sqlint8_t> result_id;
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        spike_small();
-        spike_small(const spike_small &a);
-        spike_small(const SQL_ROW &a);
-        spike_small(const std::string &s,const char *tag="spike_small");
-        spike_small &operator =(const spike_small &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="spike_small") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="spike_small");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	spike_small();
+	spike_small(const spike_small &a);
+	spike_small(const SQL_ROW &a);
+	spike_small(const std::string &s,const char *tag="spike_small");
+	spike_small &operator =(const spike_small &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="spike_small") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="spike_small");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  autocorr  : public db_table<autocorr> {
-    public:
-        sqlint8_t  id;
-#ifdef NEBULA
-        DB_REF result_id;
-#else
-        db_reference<result,sqlint8_t> result_id;
-#endif
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  delay;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        autocorr();
-        autocorr(const autocorr &a);
-        autocorr(const SQL_ROW &a);
-        autocorr(const std::string &s,const char *tag="autocorr");
-        autocorr &operator =(const autocorr &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="autocorr") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="autocorr");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  delay;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	autocorr();
+	autocorr(const autocorr &a);
+	autocorr(const SQL_ROW &a);
+	autocorr(const std::string &s,const char *tag="autocorr");
+	autocorr &operator =(const autocorr &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="autocorr") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="autocorr");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  autocorr_small  : public db_table<autocorr_small> {
-    public:
-        sqlint8_t  id;
-        db_reference<result,sqlint8_t> result_id;
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  delay;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        autocorr_small();
-        autocorr_small(const autocorr_small &a);
-        autocorr_small(const SQL_ROW &a);
-        autocorr_small(const std::string &s,const char *tag="autocorr_small");
-        autocorr_small &operator =(const autocorr_small &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="autocorr_small") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="autocorr_small");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  delay;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	autocorr_small();
+	autocorr_small(const autocorr_small &a);
+	autocorr_small(const SQL_ROW &a);
+	autocorr_small(const std::string &s,const char *tag="autocorr_small");
+	autocorr_small &operator =(const autocorr_small &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="autocorr_small") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="autocorr_small");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  classic_versions  : public db_table<classic_versions> {
-    public:
-        long  id;
-        long  ver_major;
-        long  ver_minor;
-        long  platformid;
-        char  comment[254];
-        char  filename[254];
-        char  md5_cksum[254];
-        char  sum_cksum[254];
-        char  cksum_cksum[254];
-        long  file_cksum;
-        classic_versions();
-        classic_versions(const classic_versions &a);
-        classic_versions(const SQL_ROW &a);
-        classic_versions(const std::string &s,const char *tag="classic_versions");
-        classic_versions &operator =(const classic_versions &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="classic_versions") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="classic_versions");
+  public:
+	long  id;
+	long  ver_major;
+	long  ver_minor;
+	long  platformid;
+	char  comment[254];
+	char  filename[254];
+	char  md5_cksum[254];
+	char  sum_cksum[254];
+	char  cksum_cksum[254];
+	long  file_cksum;
+	classic_versions();
+	classic_versions(const classic_versions &a);
+	classic_versions(const SQL_ROW &a);
+	classic_versions(const std::string &s,const char *tag="classic_versions");
+	classic_versions &operator =(const classic_versions &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="classic_versions") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="classic_versions");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  classic_active_versions  : public db_table<classic_active_versions> {
-    public:
-        long  id;
-        long  versionid;
-        long  ver_major;
-        long  ver_minor;
-        classic_active_versions();
-        classic_active_versions(const classic_active_versions &a);
-        classic_active_versions(const SQL_ROW &a);
-        classic_active_versions(const std::string &s,const char *tag="classic_active_versions");
-        classic_active_versions &operator =(const classic_active_versions &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="classic_active_versions") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="classic_active_versions");
+  public:
+	long  id;
+	long  versionid;
+	long  ver_major;
+	long  ver_minor;
+	classic_active_versions();
+	classic_active_versions(const classic_active_versions &a);
+	classic_active_versions(const SQL_ROW &a);
+	classic_active_versions(const std::string &s,const char *tag="classic_active_versions");
+	classic_active_versions &operator =(const classic_active_versions &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="classic_active_versions") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="classic_active_versions");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  classic_active_versionids  : public db_table<classic_active_versionids> {
-    public:
-        long  id;
-        long  versionid;
-        classic_active_versionids();
-        classic_active_versionids(const classic_active_versionids &a);
-        classic_active_versionids(const SQL_ROW &a);
-        classic_active_versionids(const std::string &s,const char *tag="classic_active_versionids");
-        classic_active_versionids &operator =(const classic_active_versionids &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="classic_active_versionids") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="classic_active_versionids");
+  public:
+	long  id;
+	long  versionid;
+	classic_active_versionids();
+	classic_active_versionids(const classic_active_versionids &a);
+	classic_active_versionids(const SQL_ROW &a);
+	classic_active_versionids(const std::string &s,const char *tag="classic_active_versionids");
+	classic_active_versionids &operator =(const classic_active_versionids &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="classic_active_versionids") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="classic_active_versionids");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  rfi_zone  : public db_table<rfi_zone> {
-    public:
-        long  id;
-        long  min_receiver_s4id;
-        long  max_receiver_s4id;
-        long  min_splitter_config;
-        long  max_splitter_config;
-        long  min_analysis_config;
-        long  max_analysis_config;
-        long  min_tape_id;
-        long  max_tape_id;
-        sqlint8_t  min_workunit_id;
-        sqlint8_t  max_workunit_id;
-        sqlint8_t  min_result_id;
-        sqlint8_t  max_result_id;
-        double  min_time;
-        double  max_time;
-        double  central_baseband_freq;
-        double  baseband_freq_width;
-        double  central_detection_freq;
-        double  detection_freq_width;
-        double  central_period;
-        double  period_width;
-        long  fft_len_flags;
-        long  signal_type_flags;
-        double  ra;
-        double  dec;
-        double  angular_distance;
-        rfi_zone();
-        rfi_zone(const rfi_zone &a);
-        rfi_zone(const SQL_ROW &a);
-        rfi_zone(const std::string &s,const char *tag="rfi_zone");
-        rfi_zone &operator =(const rfi_zone &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="rfi_zone") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="rfi_zone");
+  public:
+	long  id;
+	long  min_receiver_s4id;
+	long  max_receiver_s4id;
+	long  min_splitter_config;
+	long  max_splitter_config;
+	long  min_analysis_config;
+	long  max_analysis_config;
+	long  min_tape_id;
+	long  max_tape_id;
+	sqlint8_t  min_workunit_id;
+	sqlint8_t  max_workunit_id;
+	sqlint8_t  min_result_id;
+	sqlint8_t  max_result_id;
+	double  min_time;
+	double  max_time;
+	double  central_baseband_freq;
+	double  baseband_freq_width;
+	double  central_detection_freq;
+	double  detection_freq_width;
+	double  central_period;
+	double  period_width;
+	long  fft_len_flags;
+	long  signal_type_flags;
+	double  ra;
+	double  dec;
+	double  angular_distance;
+	rfi_zone();
+	rfi_zone(const rfi_zone &a);
+	rfi_zone(const SQL_ROW &a);
+	rfi_zone(const std::string &s,const char *tag="rfi_zone");
+	rfi_zone &operator =(const rfi_zone &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="rfi_zone") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="rfi_zone");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  bad_data  : public db_table<bad_data> {
-    public:
-        char  name[20];
-        long  beam;
-        char  reason[255];
-        bad_data();
-        bad_data(const bad_data &a);
-        bad_data(const SQL_ROW &a);
-        bad_data(const std::string &s,const char *tag="bad_data");
-        bad_data &operator =(const bad_data &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="bad_data") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="bad_data");
+  public:
+	char  name[128];
+	long  beam;
+	char  reason[255];
+	bad_data();
+	bad_data(const bad_data &a);
+	bad_data(const SQL_ROW &a);
+	bad_data(const std::string &s,const char *tag="bad_data");
+	bad_data &operator =(const bad_data &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="bad_data") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="bad_data");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  spike_tinysky  : public db_table<spike_tinysky> {
-    public:
-        sqlint8_t  id;
-        db_reference<result,sqlint8_t> result_id;
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        spike_tinysky();
-        spike_tinysky(const spike_tinysky &a);
-        spike_tinysky(const SQL_ROW &a);
-        spike_tinysky(const std::string &s,const char *tag="spike_tinysky");
-        spike_tinysky &operator =(const spike_tinysky &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="spike_tinysky") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="spike_tinysky");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	spike_tinysky();
+	spike_tinysky(const spike_tinysky &a);
+	spike_tinysky(const SQL_ROW &a);
+	spike_tinysky(const std::string &s,const char *tag="spike_tinysky");
+	spike_tinysky &operator =(const spike_tinysky &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="spike_tinysky") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="spike_tinysky");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  gaussian_tinysky  : public db_table<gaussian_tinysky> {
-    public:
-        sqlint8_t  id;
-        db_reference<result,sqlint8_t> result_id;
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        double  sigma;
-        double  chisqr;
-        double  null_chisqr;
-        double  score;
-        double  max_power;
-        sqlblob<unsigned char>  pot;
-        gaussian_tinysky();
-        gaussian_tinysky(const gaussian_tinysky &a);
-        gaussian_tinysky(const SQL_ROW &a);
-        gaussian_tinysky(const std::string &s,const char *tag="gaussian_tinysky");
-        gaussian_tinysky &operator =(const gaussian_tinysky &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="gaussian_tinysky") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="gaussian_tinysky");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	double  sigma;
+	double  chisqr;
+	double  null_chisqr;
+	double  score;
+	double  max_power;
+	sqlblob<unsigned char>  pot;
+	gaussian_tinysky();
+	gaussian_tinysky(const gaussian_tinysky &a);
+	gaussian_tinysky(const SQL_ROW &a);
+	gaussian_tinysky(const std::string &s,const char *tag="gaussian_tinysky");
+	gaussian_tinysky &operator =(const gaussian_tinysky &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="gaussian_tinysky") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="gaussian_tinysky");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  pulse_tinysky  : public db_table<pulse_tinysky> {
-    public:
-        sqlint8_t  id;
-        db_reference<result,sqlint8_t> result_id;
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        double  period;
-        double  snr;
-        double  thresh;
-        double  score;
-        long  len_prof;
-        sqlblob<unsigned char>  pot;
-        pulse_tinysky();
-        pulse_tinysky(const pulse_tinysky &a);
-        pulse_tinysky(const SQL_ROW &a);
-        pulse_tinysky(const std::string &s,const char *tag="pulse_tinysky");
-        pulse_tinysky &operator =(const pulse_tinysky &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="pulse_tinysky") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="pulse_tinysky");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	double  period;
+	double  snr;
+	double  thresh;
+	double  score;
+	long  len_prof;
+	sqlblob<unsigned char>  pot;
+	pulse_tinysky();
+	pulse_tinysky(const pulse_tinysky &a);
+	pulse_tinysky(const SQL_ROW &a);
+	pulse_tinysky(const std::string &s,const char *tag="pulse_tinysky");
+	pulse_tinysky &operator =(const pulse_tinysky &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="pulse_tinysky") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="pulse_tinysky");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  triplet_tinysky  : public db_table<triplet_tinysky> {
-    public:
-        sqlint8_t  id;
-        db_reference<result,sqlint8_t> result_id;
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        double  period;
-        triplet_tinysky();
-        triplet_tinysky(const triplet_tinysky &a);
-        triplet_tinysky(const SQL_ROW &a);
-        triplet_tinysky(const std::string &s,const char *tag="triplet_tinysky");
-        triplet_tinysky &operator =(const triplet_tinysky &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="triplet_tinysky") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="triplet_tinysky");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	double  period;
+	triplet_tinysky();
+	triplet_tinysky(const triplet_tinysky &a);
+	triplet_tinysky(const SQL_ROW &a);
+	triplet_tinysky(const std::string &s,const char *tag="triplet_tinysky");
+	triplet_tinysky &operator =(const triplet_tinysky &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="triplet_tinysky") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="triplet_tinysky");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
 class  autocorr_tinysky  : public db_table<autocorr_tinysky> {
-    public:
-        sqlint8_t  id;
-        db_reference<result,sqlint8_t> result_id;
-        double  peak_power;
-        double  mean_power;
-        double  time;
-        double  ra;
-        double  decl;
-        sqlint8_t  q_pix;
-        double  delay;
-        double  freq;
-        double  detection_freq;
-        double  barycentric_freq;
-        long  fft_len;
-        double  chirp_rate;
-        long  rfi_checked;
-        long  rfi_found;
-        long  reserved;
-        autocorr_tinysky();
-        autocorr_tinysky(const autocorr_tinysky &a);
-        autocorr_tinysky(const SQL_ROW &a);
-        autocorr_tinysky(const std::string &s,const char *tag="autocorr_tinysky");
-        autocorr_tinysky &operator =(const autocorr_tinysky &a);
-        std::string update_format() const;
-        std::string insert_format() const;
-        std::string select_format() const;
-        std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
-        std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="autocorr_tinysky") const;
-        void parse(const SQL_ROW &s);
-        void parse(const std::string &s);
-        void parse_xml(const std::string &s,const char *tag="autocorr_tinysky");
+  public:
+	sqlint8_t  id;
+	db_reference<result,sqlint8_t> result_id;
+	double  peak_power;
+	double  mean_power;
+	double  time;
+	double  ra;
+	double  decl;
+	sqlint8_t  q_pix;
+	double  delay;
+	double  freq;
+	double  detection_freq;
+	double  barycentric_freq;
+	long  fft_len;
+	double  chirp_rate;
+	long  rfi_checked;
+	long  rfi_found;
+	long  reserved;
+	autocorr_tinysky();
+	autocorr_tinysky(const autocorr_tinysky &a);
+	autocorr_tinysky(const SQL_ROW &a);
+	autocorr_tinysky(const std::string &s,const char *tag="autocorr_tinysky");
+	autocorr_tinysky &operator =(const autocorr_tinysky &a);
+	std::string update_format() const;
+	std::string insert_format() const;
+	std::string select_format() const;
+	std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const;
+	std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=0,const char *tag="autocorr_tinysky") const;
+	void parse(const SQL_ROW &s);
+	void parse(const std::string &s);
+	void parse_xml(const std::string &s,const char *tag="autocorr_tinysky");
 #ifdef NEBULA
-        bool nebula_read(FILE *f);
+	bool nebula_read(FILE *f);
 #endif
-    private:
+  private:
 };
 
 
diff --git a/db/schema_master.sql b/db/schema_master.sql
index 30f4203..799ab92 100644
--- a/db/schema_master.sql
+++ b/db/schema_master.sql
@@ -117,7 +117,8 @@ create table splitter_config
     highpass smallfloat default 0 not null,             
     blanker_filter char(64) default "none" not null,
     pfb_ntaps integer not null,
-    pfb_width_factor smallfloat not null
+    pfb_width_factor smallfloat not null,
+    wu_bits_per_sample integer default 2 not null
   );
 
 
@@ -248,6 +249,43 @@ create table meta_candidate
                                                    -- 2 : this is a stable and clean candidate
   );
 
+create table meta_candidate_tinysky
+  (
+    id serial8 not null,
+    version                     integer not null,
+    time_last_updated           float not null,
+    num_spikes                  integer not null,
+    num_spike_b_multiplets      integer not null,
+    best_spike_b_mp_score       float not null,
+    num_spike_nb_multiplets     integer not null,
+    best_spike_nb_mp_score      float not null,
+    spike_high_id               int8 not null,
+    num_gaussians               integer not null,
+    num_gaussian_b_multiplets   integer not null,
+    best_gaussian_b_mp_score    float not null,
+    num_gaussian_nb_multiplets  integer not null,
+    best_gaussian_nb_mp_score   float not null,
+    gaussian_high_id            int8 not null,
+    num_pulses                  integer not null,
+    num_pulse_b_multiplets      integer not null,
+    best_pulse_b_mp_score       float not null,
+    num_pulse_nb_multiplets     integer not null,
+    best_pulse_nb_mp_score      float not null,
+    pulse_high_id               int8 not null,
+    num_triplets                integer not null,
+    num_triplet_b_multiplets    integer not null,
+    best_triplet_b_mp_score     float not null,
+    num_triplet_nb_multiplets   integer not null,
+    best_triplet_nb_mp_score    float not null,
+    triplet_high_id             int8 not null,
+    num_stars                   integer not null,
+    best_star_score             float not null,
+    meta_score                  float not null,
+    rfi_clean                   integer,
+    state                       smallint           -- 0 : the ntpckr has (re)scored this MC - rfi should look at it
+                                                   -- 1 : the signal set has changed - ntpckr should look at it
+                                                   -- 2 : this is a stable and clean candidate
+  );
 
 create table  multiplet 
   (
@@ -324,7 +362,7 @@ create table candidate_count
 create table tape 
   (
     id serial primary key,
-    name char(20) not null ,
+    name char(128) not null ,
     start_time float not null ,
     last_block_time float not null ,
     last_block_done integer not null ,
@@ -353,7 +391,7 @@ create table workunit_grp
   (
     id serial primary key,
     tape_info integer not null ,			--references tape
-    name char(64) not null ,
+    name char(128) not null ,
     data_desc data_description_t,
     receiver_cfg integer references receiver_config,
     recorder_cfg integer references recorder_config,
@@ -369,7 +407,7 @@ create table workunit_grp
 create table workunit_header 
   (
     id serial8 primary key,
-    name char(64) not null ,
+    name char(128) not null ,
     group_info integer not null ,   -- references workunit_grp
     subband_desc subband_description_t,
     sb_id int8
@@ -623,6 +661,11 @@ create table hotpix
         last_hit_time           int
    );
 
+create table hotpix_tinysky
+   (
+        id                      int,            -- qpix
+        last_hit_time           int
+   );
 
 create table spike 
   (
@@ -796,7 +839,7 @@ create table rfi_zone
 
 create table bad_data
   (
-  name char(20) not null,
+  name char(128) not null,
   beam integer default 0 not null,
   reason varchar(255)
   ); 
diff --git a/db/schema_to_class.awk b/db/schema_to_class.awk
index 04b2d87..3b50886 100644
--- a/db/schema_to_class.awk
+++ b/db/schema_to_class.awk
@@ -117,7 +117,20 @@ BEGIN		{
 		   print "inline int db_open() { return (db_is_open=1); }" >headerfile
 		   print "inline int db_close() { return !(db_is_open=0); }" >headerfile
 		   print "inline int db_change() { return (db_is_open=1); }" >headerfile
-		   print "#endif\n" >headerfile
+
+                   print "#ifdef NEBULA" > headerfile
+                   print "typedef sqlint8_t long;" > headerfile
+                   print "template <typename T, typename ID_TYPE=long> " > headerfile
+                   print "struct db_reference {" > headerfile
+                   print "  ID_TYPE id;" > headerfile
+                   print "  void parse_xml(std::string &buf, const char *tag) {};" >headerfile
+                   print "  void parse(const std::string &buf) {};" >headerfile
+                   print "  std::string print(int full_subtables=0, int show_ids=1, int no_refs=0) const {};" > headerfile
+                   print "  std::string print_xml(int full_subtables=1, int show_ids=0, int no_refs=1, const char *tag=0) const {};" > headerfile
+                   print "};" > headerfile
+
+		   print "#endif //NEBULA\n" >headerfile
+		   print "#endif //CLIENT || NEBULA\n" >headerfile
 		   next
 		}
 
diff --git a/db/tools/analysis_configs.xml b/db/tools/analysis_configs.xml
index 564db4c..f87e95b 100644
--- a/db/tools/analysis_configs.xml
+++ b/db/tools/analysis_configs.xml
@@ -21,8 +21,8 @@
      <triplet_pot_length>256</triplet_pot_length>
      <pot_overlap_factor>0.5</pot_overlap_factor>
      <pot_t_offset>1</pot_t_offset>
-     <pot_min_slew>0.0021</pot_min_slew>  # should be beams/s rather and degrees
-     <pot_max_slew>0.0105</pot_max_slew>  # should be beams/s rather and degrees
+     <pot_min_slew>0.0064</pot_min_slew>  # should be beams/s rather and degrees
+     <pot_max_slew>0.0320</pot_max_slew>  # should be beams/s rather and degrees
      <chirp_resolution>0.1665</chirp_resolution>
      <analysis_fft_lengths>262136</analysis_fft_lengths>
      <bsmooth_boxcar_length>8192</bsmooth_boxcar_length> # should be seconds
@@ -44,6 +44,55 @@
      <max_gaussians>0</max_gaussians>
      <max_pulses>0</max_pulses>
      <max_triplets>0</max_triplets>
-     <keyuniq>34</keyuniq>
+     <keyuniq>35</keyuniq>
+     <credit_rate>2.85</credit_rate>
+</analysis_config>
+<analysis_config>
+     <spike_thresh>24.0</spike_thresh>
+     <spikes_per_spectrum>1</spikes_per_spectrum>
+     <autocorr_thresh>17.8</autocorr_thresh>
+     <autocorr_per_spectrum>1</autocorr_per_spectrum>
+     <autocorr_fftlen>131072</autocorr_fftlen>
+     <gauss_null_chi_sq_thresh>2.225</gauss_null_chi_sq_thresh>
+     <gauss_chi_sq_thresh>1.42</gauss_chi_sq_thresh>
+     <gauss_power_thresh>3.0</gauss_power_thresh>
+     <gauss_peak_power_thresh>3.2</gauss_peak_power_thresh>
+     <gauss_pot_length>64</gauss_pot_length>
+     <pulse_thresh>19.5</pulse_thresh>
+     <pulse_display_thresh>0.5</pulse_display_thresh>
+     <pulse_max>40960</pulse_max>
+     <pulse_min>16</pulse_min>
+     <pulse_fft_max>8192</pulse_fft_max>
+     <pulse_pot_length>256</pulse_pot_length>
+     <triplet_thresh>8.50</triplet_thresh>
+     <triplet_max>131072</triplet_max>
+     <triplet_min>16</triplet_min>
+     <triplet_pot_length>256</triplet_pot_length>
+     <pot_overlap_factor>0.5</pot_overlap_factor>
+     <pot_t_offset>1</pot_t_offset>
+     <pot_min_slew>0.0010</pot_min_slew>  # should be beams/s rather and degrees
+     <pot_max_slew>0.0053</pot_max_slew>  # should be beams/s rather and degrees
+     <chirp_resolution>0.1665</chirp_resolution>
+     <analysis_fft_lengths>262136</analysis_fft_lengths>
+     <bsmooth_boxcar_length>8192</bsmooth_boxcar_length> # should be seconds
+     <bsmooth_chunk_size>32768</bsmooth_chunk_size> # should be seconds
+     <chirps>
+       <chirp_parameter_t>
+         <chirp_limit>30.0</chirp_limit>
+	 <fft_len_flags>262136</fft_len_flags>
+       </chirp_parameter_t>
+       <chirp_parameter_t>
+	 <chirp_limit>100.0</chirp_limit>
+	 <fft_len_flags>65528</fft_len_flags>
+       </chirp_parameter_t>
+     </chirps>
+     <pulse_beams>1.0</pulse_beams>
+     <max_signals>30</max_signals>
+     <max_spikes>8</max_spikes>
+     <max_autocorr>8</max_autocorr>
+     <max_gaussians>0</max_gaussians>
+     <max_pulses>0</max_pulses>
+     <max_triplets>0</max_triplets>
+     <keyuniq>36</keyuniq>
      <credit_rate>2.85</credit_rate>
 </analysis_config>
diff --git a/image_libs/Makefile b/image_libs/Makefile
new file mode 100644
index 0000000..a09375e
--- /dev/null
+++ b/image_libs/Makefile
@@ -0,0 +1,13 @@
+
+subdir = image_libs
+
+SUFFIXES = .cpp .h
+
+all: Makefile
+
+clean:
+	rm -f *.o
+
+distclean: clean
+	-rm -f Makefile
+
diff --git a/image_libs/Makefile.in b/image_libs/Makefile.in
new file mode 100644
index 0000000..a09375e
--- /dev/null
+++ b/image_libs/Makefile.in
@@ -0,0 +1,13 @@
+
+subdir = image_libs
+
+SUFFIXES = .cpp .h
+
+all: Makefile
+
+clean:
+	rm -f *.o
+
+distclean: clean
+	-rm -f Makefile
+
diff --git a/m4/ax_check_glut.m4 b/m4/ax_check_glut.m4
index a6fd5cd..7c5280c 100644
--- a/m4/ax_check_glut.m4
+++ b/m4/ax_check_glut.m4
@@ -16,14 +16,13 @@ else
   # If X is present, assume GLUT depends on it.
   #
   if test "X${no_x}" != "Xyes"; then
-    PRE_GLUT_LIBS="${X_PRE_LIBS} -L/usr/X11/lib -L/usr/X11R6/lib"
-    AC_CHECK_LIB([Xmu],[XmuMakeAtom],[
-        PRE_GLUT_LIBS="${GLUT_LIBS} -lXmu"
-    ])
-    AC_CHECK_LIB([Xi],[XAllowDeviceEvents],[
-        PRE_GLUT_LIBS="${GLUTLIBS} -lXi"
-    ])
-    GLUT_LIBS="${PRE_GLUT_LIBS} ${X_EXTRA_LIBS} ${GLUT_LIBS}"
+    GLUT_LIBS="${X_PRE_LIBS} -lXmu -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"
+  fi
+  #
+  # If were running under windows assume we need GDI32 and WinMM
+  #
+  if echo $host_os | egrep '^mingw|^winnt' > /dev/null ; then
+    GLUT_LIBS="${GLUT_LIBS} -lgdi32 -lwinmm"
   fi
 
   AC_LANG_PUSH(C)
@@ -35,22 +34,23 @@ else
   [ax_cv_check_glut_libglut="no"
   ax_save_LIBS="${LIBS}"
   LIBS=""
-  ax_check_libs="-lglut32 -lglut"
+  ax_check_libs="-lglut32 -lglut -lfreeglut_static -lfreeglut"
   for ax_lib in ${ax_check_libs}; do
     if test X$ax_compiler_ms = Xyes; then
       ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
     else
       ax_try_lib="${ax_lib}"
     fi
-    LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}"
+    LIBS="-L${prefix}/lib ${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}"
     AC_LINK_IFELSE(
     [AC_LANG_PROGRAM([[
+#define FREEGLUT_STATIC 1
 # if HAVE_WINDOWS_H && (defined(_WIN32) || defined(CYGWIN_USE_WIN32))
 #   include <windows.h>
 # endif
 # include <GL/glut.h>]],
                      [[glutMainLoop()]])],
-    [ax_cv_check_glut_libglut="${ax_try_lib}"; break])
+    [ax_cv_check_glut_libglut="-L${prefix}/lib ${ax_try_lib}"; break])
 
   done
   LIBS=${ax_save_LIBS}
diff --git a/m4/check_ssl.m4 b/m4/check_ssl.m4
index c6fc398..d0da9f5 100644
--- a/m4/check_ssl.m4
+++ b/m4/check_ssl.m4
@@ -7,7 +7,7 @@ AC_ARG_WITH(ssl,
        [Use openssl (in specified installation directory)]),
     [check_ssl_dir="$withval"],
     [check_ssl_dir=])
-for dir in $check_ssl_dir /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
+for dir in $check_ssl_dir /usr/local/ssl /usr/lib64/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
    ssldir="$dir"
    if test -f "$dir/include/openssl/ssl.h"; then
      found_ssl="yes";
@@ -36,10 +36,11 @@ if test x_$found_ssl != x_yes; then
 ])
 else
         printf "OpenSSL found in $ssldir\n";
-        LIBS="$LIBS -lssl -lcrypto";
+        SSLLIBS="-lssl -lcrypto";
         LDFLAGS="$LDFLAGS -L$ssldir/lib";
 	AC_DEFINE_UNQUOTED([USE_OPENSSL],[1],
 	  ["Define to 1 if you want to use the openssl crypto library"])
+        AC_SUBST(SSLLIBS)
 	AC_SUBST(SSLDIR)
 fi
 ])dnl
diff --git a/m4/optimizations.m4 b/m4/optimizations.m4
index 69f2505..46fba0b 100644
--- a/m4/optimizations.m4
+++ b/m4/optimizations.m4
@@ -13,7 +13,7 @@ if test x_$enable_sse3 = x_yes ; then
     [Define to 1 if you want to use SSE3 optimizations])
 # put compiler specific flags here
   if test x_$ac_cv_c_compiler_gnu = x_yes ; then
-    CFLAGS="-march=prescott -msse3  -mfpmath=sse ${CFLAGS}"
+    CFLAGS="-msse3 ${CFLAGS}"
   fi
 fi
 
@@ -27,7 +27,7 @@ if test x_$enable_sse2 = x_yes ; then
     [Define to 1 if you want to use SSE2 optimizations])
 # put compiler specific flags here
   if test x_$ac_cv_c_compiler_gnu = x_yes ; then
-    CFLAGS="-msse2 -mfpmath=sse ${CFLAGS}"
+    CFLAGS="-msse2 ${CFLAGS}"
     if test -z "echo $CFLAGS | grep march=" ; then
       CFLAGS="-march=pentium4 ${CFLAGS}" 
     fi
diff --git a/m4/sah_check_boinc.m4 b/m4/sah_check_boinc.m4
index 3378d7f..1b3026d 100644
--- a/m4/sah_check_boinc.m4
+++ b/m4/sah_check_boinc.m4
@@ -8,6 +8,7 @@ AC_PREREQ([2.54])
 AC_DEFUN([SAH_CHECK_BOINC],[
   AC_ARG_VAR([BOINCDIR],[boinc directory])
   AC_ARG_VAR([PROJECTDIR],[project config.xml directory])
+  set -x
   if test -z "$HEAD"
   then
     AC_PATH_PROG(HEAD,head)
@@ -18,7 +19,7 @@ AC_DEFUN([SAH_CHECK_BOINC],[
   fi
   thisdir=`pwd`
   AC_MSG_CHECKING([for BOINC])
-  boinc_search_path="$BOINCDIR boinc ../boinc $HOME/boinc /usr/local/boinc /usr/local/lib/boinc /opt/misc/boinc /opt/misc/lib/boinc $2"
+  boinc_search_path="$BOINCDIR /usr/local boinc ../boinc ../../boinc  /usr /usr/local /usr/local/include ${top_srcdir}../boinc $HOME/boinc /usr/local/boinc /usr/local/lib/boinc /opt/misc/boinc /opt/misc/lib/boinc $2" 
   for boinc_dir in $boinc_search_path
   do
     if test -d $boinc_dir 
@@ -30,7 +31,7 @@ AC_DEFUN([SAH_CHECK_BOINC],[
 	cd $thisdir
 	break
       else
-        if $FIND $boinc_dir -name "std_fixes.h" >& /dev/null
+        if test -n "`$FIND $boinc_dir -name 'std_fixes.h'`"
 	then
 	  BOINCDIR=`$FIND $boinc_dir -name "std_fixes.h" -print | $HEAD -1 | sed 's/\/std_fixes.h//'`         
           cd $BOINCDIR/..
@@ -55,8 +56,10 @@ AC_DEFUN([SAH_CHECK_BOINC],[
   AC_DEFINE_UNQUOTED([PROJECTDIR],["$PROJECTDIR"],[Define as directory containing the project config.xml])
   AC_SUBST([PROJECTDIR])
   AC_SUBST([BOINCDIR])
-  BOINC_CFLAGS="-I$BOINCDIR -I$BOINCDIR/api -I$BOINCDIR/lib -I$BOINCDIR/sched -I$BOINCDIR/db"
+  BOINCCFG=`find $BOINCDIR -name config.h | head -1`
+
+  BOINC_CFLAGS="-I$BOINCDIR -I$BOINCDIR/api -I$BOINCDIR/lib -I$BOINCDIR/sched -I$BOINCDIR/db -I`dirname $BOINCCFG`"
   AC_SUBST([BOINC_CFLAGS])
+  set +x
 ])
-	
 
diff --git a/m4/sah_grx.m4 b/m4/sah_grx.m4
index ec9daed..47a96a6 100644
--- a/m4/sah_grx.m4
+++ b/m4/sah_grx.m4
@@ -20,7 +20,7 @@ AC_DEFUN([SAH_GRX_INCLUDES],[
   CFLAGS=`echo $CFLAGS "-I$sah_xpath/include"`
   GRX_CFLAGS="-I$sah_xpath"
   AC_SUBST(GRX_CFLAGS)
-  AC_CHECK_HEADERS([gl.h glu.h glut.h glaux.h GL/gl.h GL/glu.h GL/glut.h GL/glaux.h OpenGL/gl.h OpenGL/glu.h OpenGL/glut.h OpenGL/glaux.h glut/glut.h MesaGL/gl.h MesaGL/glu.h MesaGL/glut.h MesaGL/glaux.h])
+  AC_CHECK_HEADERS([gl.h glu.h glut.h freeglut.h glaux.h GL/gl.h GL/glu.h GL/glut.h GL/freeglut.h GL/glaux.h OpenGL/gl.h OpenGL/glu.h OpenGL/glut.h OpenGL/freeglut.h OpenGL/glaux.h glut/glut.h glut/freeglut.h freeglut/freeglut.h MesaGL/gl.h MesaGL/glu.h MesaGL/glut.h MesaGL/freeglut.h MesaGL/glaux.h ])
   CFLAGS="$save_cflags"
   AC_LANG_POP
 ])
diff --git a/ops/bin/run_gbt_splitter b/ops/bin/run_gbt_splitter
new file mode 100755
index 0000000..3640fb6
--- /dev/null
+++ b/ops/bin/run_gbt_splitter
@@ -0,0 +1,264 @@
+#! /usr/bin/perl -w
+
+use locale;
+use sigtrap qw(HUP TERM INT);
+use Cwd;
+use Fcntl;
+
+$ENV{'INFORMIXDIR'} = '/usr/local/informix';
+$ENV{'INFORMIXSQLHOSTS'} = '/usr/local/informix/etc/sqlhosts';
+$ENV{'INFORMIXSERVER'} = 'sah_master_tcp';
+# $ENV{'LD_LIBRARY_PATH'} = '/usr/local/informix/lib:/usr/local/informix/lib/esql:/usr/local/lib:/usr/X11R6/lib:/usr/lib:/lib:/usr/ccs/lib:/usr/local/lib:/usr/local/ssl/lib:/usr/local/informix/lib:/usr/local/informix/lib/esql:/usr/local/generic/lib:/usr/lib64:/usr/lib64/mysql'; 
+$ENV{'LD_LIBRARY_PATH'} = '/usr/local/informix/lib:/usr/local/informix/lib/esql:/usr/local/lib:/usr/X11R6/lib:/usr/lib:/lib:/usr/ccs/lib:/usr/local/lib:/usr/local/ssl/lib:/usr/local/informix/lib:/usr/local/informix/lib/esql:/usr/local/generic/lib:/usr/lib64:/usr/lib64/mysql:/disks/carolyn/b/home/jeffc/build/sah_development/seti_gbt/lib'; 
+
+# GBT receivers must be specified with channel (0-31) and polarization (0-1), i.e. -gbt=14,0
+
+# signal handler sub
+
+sub touch_and_die {
+  print STDERR time . " run_gbt_splitter caught signal and is touching ${split_halt_msg}..\n";
+  system ("/bin/touch $split_halt_msg");
+  exit(99)
+  }
+
+sub is_completely_done {
+  my $chkfile = $_[0];
+  my $completely_done = 1;
+  my $errors = 0;
+  for (my $chkchan = 0; $chkchan < 32; $chkchan++) {
+    for (my $chkpolarization = 0; $chkpolarization < 2; $chkpolarization++) {
+      if (! -f "${chkfile}.done.${chkchan},${chkpolarization}" &&
+          ! -f "${chkfile}.ERROR.${chkchan},${chkpolarization}") { $completely_done = 0; }
+      if (  -f "${chkfile}.ERROR.${chkchan},${chkpolarization}") { $errors = 1; }
+      }
+    }
+  if ($completely_done == 1 && $errors == 1) { return -1; } # completely done, but with errors
+  return $completely_done;
+  }
+
+# project/splitter vars
+#
+# sleep(rand()*30);
+
+$betaorsah = "beta"; # set to beta or sah to set proper dirs below
+
+$mb_prog_loc = "/home/boincadm/projects/$betaorsah/bin";
+# $mb_prog_name = "mb_splitter_swb.x86_64";
+$mb_prog_name = "mb_splitter.x86_64";
+$app_name = "setiathome_v8";
+
+$project_dir = "/home/boincadm/projects/$betaorsah/";
+
+$rawbitdepth = 8;
+$file_dir = "/home/boincadm/projects/$betaorsah/processing";
+$split_halt_msg = "$project_dir/stop_splitters";
+$email_list = 'jeffc at ssl.berkeley.edu korpela at ssl.berkeley.edu mattl at ssl.berkeley.edu';
+$found_file = "0";
+$host = `/bin/uname -n | /bin/sed s/.ssl.berkeley.edu//`;
+$dovertical = 0;
+chomp $host;
+$usage = "usage: run_gbt_splitter [-vertical] [-exe executable_name] [-filedir filedir] [-app app_name]\n(assuming all executables are in: $mb_prog_loc)\n";
+
+# before anything, stagger processes by sleeping a bit
+
+ at numprocs = `pgrep -f run_gbt_splitter`;
+$sleepsecs = $#numprocs * 2;
+sleep $sleepsecs;
+
+# check args
+
+$checkhelp = $ARGV[0] || "";
+if ($checkhelp eq "-h" || $checkhelp eq "-help" || $checkhelp eq "--help") { print $usage; exit(2); }
+
+while ($ARGV[0] ne "") {
+  $tempvar = $ARGV[0];
+  if ($tempvar eq '-filedir') {
+    shift @ARGV;
+    $file_dir = $ARGV[0]
+    }
+  elsif ($tempvar eq '-exe') {
+    shift @ARGV;
+    $mb_prog_name = $ARGV[0]
+    }
+  elsif ($tempvar eq '-app') {
+    shift @ARGV;
+    $app_name = $ARGV[0]
+    }
+  elsif ($tempvar eq '-vertical') {
+    $dovertical = 1;
+    }
+  else { print $usage; exit(2); }
+  shift @ARGV;
+  }
+
+$SIG{HUP} = $SIG{TERM} = $SIG{INT} = \&touch_and_die;
+
+# main loop (run as long as halt trigger file doesn't exist)
+
+while (! -f "$split_halt_msg") {
+
+  chdir $file_dir;
+  $found_file = 0;
+
+  # get working state of directory and determine what work is available to do
+  undef @file_list;
+  open (LS,"/bin/ls -tr . |");
+  while (<LS>) { 
+    $thisfile = $_; chomp $thisfile;
+    if (/.0000.raw$/) { push @file_list, $_ }
+    }
+  close (LS);
+  chomp @file_list;
+  $dothisfile = ""; $dochan = -1; $dopolarization = -1;
+  foreach $file (@file_list) {
+    # is it a broken sym link?
+    if (! -e $file) {
+      print "${file} doesn't actually exist! (broken sym link?) skipping...\n";
+      next;
+      }
+    # are we working on this file already?
+    $isworking = 0;
+    for ($chan = 0; $chan < 32; $chan++) {
+      for ($polarization = 0; $polarization < 2; $polarization++) {
+        if (-f "${file}.working.${chan},${polarization}") { $isworking = 1; }
+        }
+      }
+    # if we're working on this file already and -vertical is set, skip it:
+    if ($isworking == 1 && $dovertical == 1) { 
+      print "${file} is being worked on and -vertical is set - moving on...\n";
+      next;
+      }
+    # check if completely done and clean up in case this hasn't happened yet
+    if (is_completely_done($file) == 1 && ! -f "${file}.completely_done") {
+      `/bin/touch ${file}.completely_done`;
+      `/bin/rm -f ${file}.done.*`;
+      }
+    if (is_completely_done($file) == -1 && ! -f "${file}.completely_done_with_errors") {
+      `/bin/touch ${file}.completely_done_with_errors`;
+      }
+    if (-f "${file}.completely_done") {
+      print "${file} is completely_done - moving on...\n";
+      next;
+      }
+    if (-f "${file}.copying_in_lando") {
+      print "${file} is currently being read in from lando - moving on...\n";
+      next;
+      }
+    if (-f "${file}.copying_in_hpss") {
+      print "${file} is currently being read in from hpss - moving on...\n";
+      next;
+      }
+    for ($chan = 0; $chan < 32; $chan++) {
+      for ($polarization = 0; $polarization < 2; $polarization++) {
+        if ($dothisfile eq "") {
+          print "trying file $file chan $chan polarization $polarization\n";
+          }
+        if (! -f "${file}.working.${chan},${polarization}" &&
+            ! -f "${file}.done.${chan},${polarization}" &&
+            ! -f "${file}.ERROR.${chan},${polarization}" &&
+            $dothisfile eq "") {
+          $dothisfile = $file;
+          $dochan = $chan;
+          $dopolarization = $polarization;
+          } # end if
+        } # end for polarization
+      } # end for chan
+    } # end foreach file
+  if ($dothisfile eq "") {
+    print "nothing to do - exiting...\n";
+    exit(6);
+    }
+  
+  print "starting splitting on file: $dothisfile chan: $dochan polarization: $dopolarization...\n";
+  
+  sysopen (WORKING,"${dothisfile}.working.${dochan},${dopolarization}",O_WRONLY|O_EXCL|O_CREAT) or die "wait a minute - race condition opening .working file - bailing!!!\n";
+  $now = `/bin/date`; chomp $now;
+  print WORKING "$host : ". time() . " ($now)\n";
+  close (WORKING);
+
+  open(MAIL, "|/usr/sbin/sendmail -t");
+  print MAIL "To: ${email_list}\n";
+  print MAIL 'From: splitters at ssl.berkeley.edu' . "\n";
+  print MAIL "Subject: splitter_gbt starting on host: ${host}\n\n";
+  print MAIL "starting file: ${dothisfile} chan: ${dochan} polarization: ${dopolarization}\n";
+  close(MAIL);
+
+  $now = `/bin/date`; chomp $now; 
+  print "$now : starting file: ${dothisfile} chan: ${dochan} polarization: ${dopolarization}\n";
+
+  $filefullpath = "${file_dir}/${dothisfile}";
+
+  mkdir "/tmp/splitter_${dothisfile}_${dochan}_${dopolarization}";
+  mkdir "/tmp/splitter_${dothisfile}_${dochan}_${dopolarization}/wu_inbox";
+  chdir "/tmp/splitter_${dothisfile}_${dochan}_${dopolarization}";
+  `/bin/rm -f wu_inbox/*`;
+
+  print "LD_LIBRARY_PATH: ";
+  print $ENV{'LD_LIBRARY_PATH'};
+  print "\n";
+
+  $splitcommand = "/bin/nice -19 /usr/bin/ionice -c2 -n7 ${mb_prog_loc}/${mb_prog_name} $filefullpath -resume -gbt=${dochan},${dopolarization} -projectdir=${project_dir} -trigger_file_path=/${split_halt_msg} -appname=${app_name} -rawbitdepth=${rawbitdepth}";
+
+  print "(running command: ${splitcommand})\n";
+
+  $retval = system ($splitcommand);
+  $retval = $retval >> 8;
+
+  print "(command exited with retval: $retval)\n";
+  
+  if ( $retval == 0 ) { # splitter_gbt ended gracefully at end of file
+    sleep 60; # wait for child process to finish moving the files from wu_inbox
+    open(MAIL, "|/usr/sbin/sendmail -t");
+    print MAIL "To: ${email_list}\n";
+    print MAIL 'From: splitters at ssl.berkeley.edu' . "\n";
+    print MAIL "Subject: splitter_gbt finishing on host: ${host}\n\n";
+    print MAIL "finished file: ${dothisfile} chan: ${dochan} polarization: ${dopolarization}\n";
+    #open (MAIL, "|/usr/ucb/mail -s \"$host splitter_gbt finished\" $email_list");
+    open (MAIL, "|/bin/mail -s \"$host splitter_gbt finished\" $email_list");
+    print MAIL "$host splitter_gbt finished on file: ${dothisfile}\n\n";
+    open (RCDCHK,"splitterlog");
+    while (<RCDCHK>) { print MAIL $_ }
+    close (RCDCHK);
+    close(MAIL);
+    if (-f "${filefullpath}.firsttry.${dochan},${dopolarization}") {
+      `/bin/touch ${filefullpath}.done.${dochan},${dopolarization}`;
+      `/bin/rm -f ${filefullpath}.firsttry.${dochan},${dopolarization}`;
+      if (is_completely_done($filefullpath) == 1 && ! -f "${filefullpath}.completely_done") {
+        `/bin/touch ${filefullpath}.completely_done`;
+        `/bin/rm -f ${filefullpath}.done.*`;
+        }
+      if (is_completely_done($filefullpath) == -1 && ! -f "${filefullpath}.completely_done_with_errors") {
+        `/bin/touch ${filefullpath}.completely_done_with_errors`;
+        }
+      }
+    else {
+      `/bin/touch ${filefullpath}.firsttry.${dochan},${dopolarization}`;
+      }
+    `/bin/rm -f ${filefullpath}.working.${dochan},${dopolarization}`;
+    chdir $file_dir;
+    `/bin/rm -rf /tmp/splitter_${dothisfile}_${dochan}_${dopolarization}`;
+    }
+  elsif ( $retval == 2 ) { # splitter_gbt ended gracefully but before finishing file
+    # remove working suffix - allows it to be resumed later
+    `/bin/rm -f ${filefullpath}.working.${dochan},${dopolarization}`;
+    chdir $file_dir;
+    `/bin/rm -rf /tmp/splitter_${dothisfile}_${dochan}_${dopolarization}`;
+    print "WARNING : splitter_gbt running on file: ${dothisfile} chan: ${dochan} polarization: ${dopolarization} ended before EOF\n";
+    }
+  else { # spitter ended in error! 
+    open(ERRFILE,">${filefullpath}.ERROR.${dochan},${dopolarization}");
+    print ERRFILE "$host\n";
+    close(ERRFILE);
+    `/bin/rm -f ${filefullpath}.working.${dochan},${dopolarization}`;
+    print "CRITICAL : splitter_gbt running on file: ${dothisfile} chan: ${dochan} polarization: ${dopolarization} ended in error!\n";
+    print "exiting run_gbt_splitter (and keeping working dir in /tmp)..\n";
+    exit(1);
+    }
+
+  $now = `/bin/date`; chomp $now; 
+  print "$now : finished running on file: ${dothisfile} chan: ${dochan} polarization: ${dopolarization}\n";
+
+  } # while halt trigger file doesn't exist
+
+print "$split_halt_msg exists - exiting..\n";
+exit (0);
diff --git a/ops/bin/run_mb_splitter b/ops/bin/run_mb_splitter
new file mode 100755
index 0000000..2721e86
--- /dev/null
+++ b/ops/bin/run_mb_splitter
@@ -0,0 +1,276 @@
+#! /usr/bin/perl -w
+
+# usage: run_mb_splitter [-filedir filedir] 
+
+use locale;
+use sigtrap qw(HUP TERM INT);
+use Cwd;
+use Fcntl;
+
+$ENV{'INFORMIXDIR'} = '/usr/local/informix';
+$ENV{'INFORMIXSQLHOSTS'} = '/usr/local/informix/etc/sqlhosts';
+$ENV{'INFORMIXSERVER'} = 'sah_master_tcp';
+$ENV{'LD_LIBRARY_PATH'} = '/usr/local/informix/lib:/usr/local/informix/lib/esql:/usr/local/lib:/usr/X11R6/lib:/usr/lib:/lib:/usr/ccs/lib:/usr/local/lib:/usr/local/ssl/lib:/usr/local/informix/lib:/usr/local/informix/lib/esql:/usr/local/generic/lib:/usr/lib64:/usr/lib64/mysql'; 
+
+# ALFA receivers must be specified with beam (0-6) and polarization (0-1), i.e. -alfa=4,0
+
+# signal handler sub
+
+sub touch_and_die {
+  print STDERR time . " run_mb_splitter caught signal and is touching ${split_halt_msg}..\n";
+  system ("/bin/touch $split_halt_msg");
+  exit(99)
+  }
+
+sub is_completely_done {
+  my $chkfile = $_[0];
+  my $completely_done = 1;
+  my $errors = 0;
+  for (my $chkbeam = 0; $chkbeam < 7; $chkbeam++) {
+    for (my $chkpolarization = 0; $chkpolarization < 2; $chkpolarization++) {
+      if (! -f "${chkfile}.done.${chkbeam},${chkpolarization}" &&
+          ! -f "${chkfile}.ERROR.${chkbeam},${chkpolarization}") { $completely_done = 0; }
+      if (  -f "${chkfile}.ERROR.${chkbeam},${chkpolarization}") { $errors = 1; }
+      }
+    }
+  if ($completely_done == 1 && $errors == 1) { return -1; } # completely done, but with errors
+  return $completely_done;
+  }
+
+# project/splitter vars
+#
+sleep(rand()*30);
+
+$mb_prog_loc = "/home/boincadm/projects/sah/bin";
+$mb_prog_name = "mb_splitter_swb.x86_64";
+$app_name = "setiathome_enhanced";
+
+$project_dir = "/home/boincadm/projects/sah/";
+
+# $file_dir = "/disks/thumper/raid5_d/users/seti/dr2_data/production/processing";
+$file_dir = "/home/boincadm/projects/sah/processing";
+$split_halt_msg = "$project_dir/stop_splitters";
+$email_list = 'jeffc at ssl.berkeley.edu korpela at ssl.berkeley.edu mattl at ssl.berkeley.edu';
+$found_file = "0";
+$host = `/bin/uname -n | /bin/sed s/.ssl.berkeley.edu//`;
+$dovertical = 0;
+chomp $host;
+$usage = "usage: run_mb_splitter [-vertical] [-exe executable_name] [-filedir filedir] [-app app_name]\n(assuming all executables are in: $mb_prog_loc)\n";
+
+
+# before anything, stagger processes by sleeping a bit
+
+ at numprocs = `pgrep -f run_mb_splitter`;
+$sleepsecs = $#numprocs * 2;
+sleep $sleepsecs;
+
+# check args
+
+$checkhelp = $ARGV[0] || "";
+if ($checkhelp eq "-h" || $checkhelp eq "-help" || $checkhelp eq "--help") { print $usage; exit(2); }
+
+while ($ARGV[0] ne "") {
+  $tempvar = $ARGV[0];
+  if ($tempvar eq '-filedir') {
+    shift @ARGV;
+    $file_dir = $ARGV[0]
+    }
+  elsif ($tempvar eq '-exe') {
+    shift @ARGV;
+    $mb_prog_name = $ARGV[0]
+    }
+  elsif ($tempvar eq '-app') {
+    shift @ARGV;
+    $app_name = $ARGV[0]
+    }
+  elsif ($tempvar eq '-vertical') {
+    $dovertical = 1;
+    }
+  else { print $usage; exit(2); }
+  shift @ARGV;
+  }
+
+$SIG{HUP} = $SIG{TERM} = $SIG{INT} = \&touch_and_die;
+
+# main loop (run as long as halt trigger file doesn't exist)
+
+while (! -f "$split_halt_msg") {
+
+  chdir $file_dir;
+  $found_file = 0;
+
+  # get working state of directory and determine what work is available to do
+  undef @file_list;
+  # NOTE: slurp in 2000-2007 files first, then 2008-2009 files, then anything after 2010
+  open (LS,"/bin/ls -tr . |");
+  while (<LS>) { 
+    $thisfile = $_; chomp $thisfile;
+    if (/^[0-9][0-9][a-z][a-z]0[0-7][a-z][a-z]$/) { push @file_list, $_ }
+    }
+  close (LS);
+  open (LS,"/bin/ls -tr . |");
+  while (<LS>) { 
+    $thisfile = $_; chomp $thisfile;
+    if (/^[0-9][0-9][a-z][a-z]0[8-9][a-z][a-z]$/) { push @file_list, $_ }
+    }
+  close (LS);
+  open (LS,"/bin/ls -tr . |");
+  while (<LS>) { 
+    $thisfile = $_; chomp $thisfile;
+    if (/^[0-9][0-9][a-z][a-z][1-9][0-9][a-z][a-z]$/) { push @file_list, $_ }
+    }
+  close (LS);
+  chomp @file_list;
+  $dothisfile = ""; $dobeam = -1; $dopolarization = -1;
+  foreach $file (@file_list) {
+    # is it a broken sym link?
+    if (! -e $file) {
+      print "${file} doesn't actually exist! (broken sym link?) skipping...\n";
+      next;
+      }
+    # are we working on this file already?
+    $isworking = 0;
+    for ($beam = 0; $beam < 7; $beam++) {
+      for ($polarization = 0; $polarization < 2; $polarization++) {
+        if (-f "${file}.working.${beam},${polarization}") { $isworking = 1; }
+        }
+      }
+    # if we're working on this file already and -vertical is set, skip it:
+    if ($isworking == 1 && $dovertical == 1) { 
+      print "${file} is being worked on and -vertical is set - moving on...\n";
+      next;
+      }
+    # check if completely done and clean up in case this hasn't happened yet
+    if (is_completely_done($file) == 1 && ! -f "${file}.completely_done") {
+      `/bin/touch ${file}.completely_done`;
+      `/bin/rm -f ${file}.done.*`;
+      }
+    if (is_completely_done($file) == -1 && ! -f "${file}.completely_done_with_errors") {
+      `/bin/touch ${file}.completely_done_with_errors`;
+      }
+    if (-f "${file}.completely_done") {
+      print "${file} is completely_done - moving on...\n";
+      next;
+      }
+    if (-f "${file}.copying_in_lando") {
+      print "${file} is currently being read in from lando - moving on...\n";
+      next;
+      }
+    if (-f "${file}.copying_in_hpss") {
+      print "${file} is currently being read in from hpss - moving on...\n";
+      next;
+      }
+    for ($beam = 0; $beam < 7; $beam++) {
+      for ($polarization = 0; $polarization < 2; $polarization++) {
+        if ($dothisfile eq "") {
+          print "trying file $file beam $beam polarization $polarization\n";
+          }
+        if (! -f "${file}.working.${beam},${polarization}" &&
+            ! -f "${file}.done.${beam},${polarization}" &&
+            ! -f "${file}.ERROR.${beam},${polarization}" &&
+            $dothisfile eq "") {
+          $dothisfile = $file;
+          $dobeam = $beam;
+          $dopolarization = $polarization;
+          } # end if
+        } # end for polarization
+      } # end for beam
+    } # end foreach file
+  if ($dothisfile eq "") {
+    print "nothing to do - exiting...\n";
+    exit(6);
+    }
+  
+  print "starting splitting on file: $dothisfile beam: $dobeam polarization: $dopolarization...\n";
+  
+  sysopen (WORKING,"${dothisfile}.working.${dobeam},${dopolarization}",O_WRONLY|O_EXCL|O_CREAT) or die "wait a minute - race condition opening .working file - bailing!!!\n";
+  $now = `/bin/date`; chomp $now;
+  print WORKING "$host : ". time() . " ($now)\n";
+  close (WORKING);
+
+  open(MAIL, "|/usr/sbin/sendmail -t");
+  print MAIL "To: ${email_list}\n";
+  print MAIL 'From: splitters at ssl.berkeley.edu' . "\n";
+  print MAIL "Subject: splitter starting on host: ${host}\n\n";
+  print MAIL "starting file: ${dothisfile} beam: ${dobeam} polarization: ${dopolarization}\n";
+  close(MAIL);
+
+  $now = `/bin/date`; chomp $now; 
+  print "$now : starting file: ${dothisfile} beam: ${dobeam} polarization: ${dopolarization}\n";
+
+  $filefullpath = "${file_dir}/${dothisfile}";
+
+  mkdir "/tmp/splitter_${dothisfile}_${dobeam}_${dopolarization}";
+  mkdir "/tmp/splitter_${dothisfile}_${dobeam}_${dopolarization}/wu_inbox";
+  chdir "/tmp/splitter_${dothisfile}_${dobeam}_${dopolarization}";
+  `/bin/rm -f wu_inbox/*`;
+
+  print "LD_LIBRARY_PATH: ";
+  print $ENV{'LD_LIBRARY_PATH'};
+  print "\n";
+
+  $splitcommand = "/bin/nice -19 /usr/bin/ionice -c2 -n7 ${mb_prog_loc}/${mb_prog_name} $filefullpath -resume -alfa=${dobeam},${dopolarization} -projectdir=${project_dir} -trigger_file_path=/${split_halt_msg} -appname=${app_name}";
+
+  print "(running command: ${splitcommand})\n";
+
+  $retval = system ($splitcommand);
+  $retval = $retval >> 8;
+
+  print "(command exited with retval: $retval)\n";
+  
+  if ( $retval == 0 ) { # splitter ended gracefully at end of file
+    sleep 60; # wait for child process to finish moving the files from wu_inbox
+    open(MAIL, "|/usr/sbin/sendmail -t");
+    print MAIL "To: ${email_list}\n";
+    print MAIL 'From: splitters at ssl.berkeley.edu' . "\n";
+    print MAIL "Subject: splitter finishing on host: ${host}\n\n";
+    print MAIL "finished file: ${dothisfile} beam: ${dobeam} polarization: ${dopolarization}\n";
+    #open (MAIL, "|/usr/ucb/mail -s \"$host splitter finished\" $email_list");
+    open (MAIL, "|/bin/mail -s \"$host splitter finished\" $email_list");
+    print MAIL "$host splitter finished on file: ${dothisfile}\n\n";
+    open (RCDCHK,"splitterlog");
+    while (<RCDCHK>) { print MAIL $_ }
+    close (RCDCHK);
+    close(MAIL);
+    if (-f "${filefullpath}.firsttry.${dobeam},${dopolarization}") {
+      `/bin/touch ${filefullpath}.done.${dobeam},${dopolarization}`;
+      `/bin/rm -f ${filefullpath}.firsttry.${dobeam},${dopolarization}`;
+      if (is_completely_done($filefullpath) == 1 && ! -f "${filefullpath}.completely_done") {
+        `/bin/touch ${filefullpath}.completely_done`;
+        `/bin/rm -f ${filefullpath}.done.*`;
+        }
+      if (is_completely_done($filefullpath) == -1 && ! -f "${filefullpath}.completely_done_with_errors") {
+        `/bin/touch ${filefullpath}.completely_done_with_errors`;
+        }
+      }
+    else {
+      `/bin/touch ${filefullpath}.firsttry.${dobeam},${dopolarization}`;
+      }
+    `/bin/rm -f ${filefullpath}.working.${dobeam},${dopolarization}`;
+    chdir $file_dir;
+    `/bin/rm -rf /tmp/splitter_${dothisfile}_${dobeam}_${dopolarization}`;
+    }
+  elsif ( $retval == 2 ) { # splitter ended gracefully but before finishing file
+    # remove working suffix - allows it to be resumed later
+    `/bin/rm -f ${filefullpath}.working.${dobeam},${dopolarization}`;
+    chdir $file_dir;
+    `/bin/rm -rf /tmp/splitter_${dothisfile}_${dobeam}_${dopolarization}`;
+    print "WARNING : splitter running on file: ${dothisfile} beam: ${dobeam} polarization: ${dopolarization} ended before EOF\n";
+    }
+  else { # spitter ended in error! 
+    open(ERRFILE,">${filefullpath}.ERROR.${dobeam},${dopolarization}");
+    print ERRFILE "$host\n";
+    close(ERRFILE);
+    `/bin/rm -f ${filefullpath}.working.${dobeam},${dopolarization}`;
+    print "CRITICAL : splitter running on file: ${dothisfile} beam: ${dobeam} polarization: ${dopolarization} ended in error!\n";
+    print "exiting run_mb_splitter (and keeping working dir in /tmp)..\n";
+    exit(1);
+    }
+
+  $now = `/bin/date`; chomp $now; 
+  print "$now : finished running on file: ${dothisfile} beam: ${dobeam} polarization: ${dopolarization}\n";
+
+  } # while halt trigger file doesn't exist
+
+print "$split_halt_msg exists - exiting..\n";
+exit (0);
diff --git a/ops/bin/splitter_janitor b/ops/bin/splitter_janitor
new file mode 100755
index 0000000..0085c34
--- /dev/null
+++ b/ops/bin/splitter_janitor
@@ -0,0 +1,276 @@
+#! /usr/bin/perl -w
+
+# where is the data?
+# $file_dir = "/disks/thumper/raid5_d/users/seti/dr2_data/production/processing";
+$file_dir = "/home/seti/dr2_data/production/processing";
+
+# $email_list = 'jeffc at ssl.berkeley.edu mattl at ssl.berkeley.edu korpela at ssl.berkeley.edu';
+# $email_list = 'jeffc at ssl.berkeley.edu';
+$email_list = 'mattl at ssl.berkeley.edu jeffc at ssl.berkeley.edu';
+
+# num of seconds to keep files in _TO_BE_DELETED before actually deleting them
+$keep_for = 7*86400; # one week
+#$keep_for = 86400; # one day
+
+# what if we are missing beam/pol pairs out of the standard 14? should we move date to be deleted anyway?
+# 0 - no, 1 - yes;
+$delete_even_if_missing_beampols = 1;
+
+# where is seti_hsi.csh?
+$seti_hsi = "/home/boincadm/projects/sah/bin/seti_hsi.csh";
+
+# set informix env
+
+$informixdir = "/usr/local/informix";
+$currentpath = $ENV{"PATH"};
+$currentldlp = $ENV{"LD_LIBRARY_PATH"};
+$ENV{"INFORMIXDIR"}="${informixdir}";
+$ENV{"INFORMIXSERVER"}="sah_master_tcp";
+$ENV{"ONCONFIG"}="onconfig.sah_master";
+$ENV{"PATH"}="${informixdir}/bin:${currentpath}";
+$ENV{"LD_LIBRARY_PATH"}="${informixdir}/lib:${informixdir}/lib/esql:${currentldlp}";
+
+# if --check_only flag is specified, do "check only" for current directory, ignoring dot files, etc.
+# basically just check for existence at HPSS, and if all 14 tapes are in science db and
+# mail us the results without moving/deleting anything.
+
+# if --not_at_hpss flag is specified, this supercedes --check_only - and only outputs what files
+# are here at the lab and fully split/processed, but not yet copied to HPSS
+
+# if --ignore_matching_sizes is specified, ignore if files don't match in size - delete anyway if
+# otherwise deleteable
+
+# if --dir flag is specified, go into that file_dir instead of default file_dir
+
+sub is_ap_doing_anything {
+    my $chkfile = $_[0];
+    if (-f "${chkfile}.completely_done_ap") { return 0; } # it's done - so better not be doing anything
+    if (-f "${chkfile}.completely_done_with_errors_ap") { return 0; } # it's done - so better not be doing anything
+    @aplist = `/bin/ls *${chkfile}*_ap.* 2>&1 | /bin/grep -v "No such"`;
+    if (scalar(@aplist) > 0) { return 1; } 
+    return 0;
+}
+
+$check_only = 0;
+$not_at_hpss = 0;
+$ignore_matching_sizes = 0;
+while ($arg = shift) {
+  if ($arg eq "--check_only") {
+    $file_dir = `pwd`;
+    chomp $file_dir;
+    $check_only = 1;
+    }
+  elsif ($arg eq "--not_at_hpss") {
+    $not_at_hpss = 1;
+    }
+  elsif ($arg eq "--ignore_matching_sizes") {
+    $ignore_matching_sizes = 1;
+    }
+  elsif ($arg eq "--dir") {
+    $file_dir = shift;
+    }
+  else {
+    print "splitter_janitor [--dir file_dir] [--check_only|--not_at_hpss]\n";
+    exit(1);
+    }
+  }
+
+# get data file list
+
+if (! -d $file_dir) { 
+  print "no such directory: $file_dir\n";
+  exit(1);
+  }
+chdir $file_dir;
+undef @file_list;
+open (LS,"/bin/ls . |");
+while (<LS>) { 
+  $thisfile = $_; chomp $thisfile;
+  if (/^[0-9][0-9][a-z][a-z][0-9][0-9][a-z][a-z]$/) { push @file_list, $_ }
+  }
+close (LS);
+chomp @file_list;
+
+$message = "Splitter Janitor Results:\n";
+if ($check_only == 1) {
+  $message .= "(doing check on data files in: $file_dir)\n";
+  }
+
+# is HPSS unavailable? if so, set warning, and undefine file_list and set check_only == 1
+# in order to go right to mail at end (don't care if we're doing not_at_hpss check)
+
+if ($not_at_hpss == 0) {
+  $check_hpss = `$seti_hsi --check`;
+  chomp $check_hpss;
+  if ($check_hpss eq "hpss is down") {
+    undef @file_list;
+    $check_only = 1;
+    $message .= "\nHPSS is currently unavailable - bailing...\n";
+    }
+  } 
+
+# moving on - main part:
+
+foreach $file (@file_list) {
+  $message .= "\n";
+  if ($not_at_hpss == 1 && 
+      ( -f "${file}.completely_done" || -f "${file}.completely_done_with_errors") &&
+      ( -f "${file}.completely_done_ap" || -f "${file}.completely_done_with_errors_ap") &&
+      ! -f "${file}.at_hpss") { 
+    print "${file}\n";
+    }
+  elsif ($not_at_hpss == 0) {
+    if (! -f "${file}.at_hpss") {
+      $hsicommand = "$seti_hsi --list $file";
+      $retval = system ($hsicommand . "> /dev/null");
+      $retval = $retval >> 8;
+      if ($retval == 0) {
+        $message .= "${file}: had no .at_hpss suffix but actually IS at HPSS - touching ${file}.at_hpss\n";
+        system ("/bin/touch ${file}.at_hpss");
+        }
+      }
+    if (( (-f "${file}.completely_done" || -f "${file}.completely_done_with_errors") &&
+          (-f "${file}.completely_done_ap" || -f "${file}.completely_done_with_errors_ap") &&
+          -f "${file}.at_hpss") || $check_only == 1) {
+      $message .= "${file}: finished processing and xfering to hpss - checking...\n";
+      $domove = 1;
+      # double check that it is at HPSS
+      $hsicommand = "$seti_hsi --list $file";
+      $retval = system ($hsicommand . "> /dev/null");
+      $retval = $retval >> 8;
+      if ($retval == 1) {
+        $message .= "WARNING: ${file}: has .at_hpss suffix but IS NOT AT HPSS!\n";
+        # $domove = 0; # just a warning... still move if need be
+        }
+      else { 
+        $message .= "${file}: is at HPSS\n";
+        # now check that local/remote file sizes match     
+        $fsize = (stat($file))[7];
+		print "DEBUG: file size: - $fsize - \n";
+        $hsifsize = `$hsicommand | awk '{print \$5}'`;
+        chomp $hsifsize;
+        if ($fsize != $hsifsize && !$ignore_matching_sizes) {
+          $message .= "${file}: local size: $fsize HPSS size: $hsifsize -- DO NOT MATCH\n";
+          $domove = 0;
+          if (($hsifsize - $fsize) <= (134742016 * 5)) { # due to ragged files/software blanking - off by less then five buffers
+            $message .= "${file}: ... but the HSI size is <= 134742016 x 5 bytes (five buffers) different\n";
+            $message .= "${file}: ... we will assume due to ragged files/etc. and flag it as okay\n";
+            $domove = 1;
+            }
+          }
+        else { $message .= "${file}: local size: $fsize and HPSS size: $hsifsize match\n"; }
+        }
+      # final check - scan science database to make sure 
+      $dbcount = `echo "database sah2; select count(name) from tape where name = '${file}';" | dbaccess -e - 2>&1 | tail --l=+8 | head -1 | awk '{print \$1}'`;
+      chomp $dbcount;
+      if ($dbcount != 14) {
+        $message .= "${file}: multibeam does not have 14 entries in the tape table!\n";
+        if ($delete_even_if_missing_beampols == 0) { # i.e. if we want to keep tapes around with missing beam/pol entries, then...
+          $domove = 0;
+          }
+        }
+      else { $message .= "${file}: has all 14 entries in the tape table\n"; }
+      if ($domove == 1) { 
+        if ($check_only == 1) {
+          $message .= "${file}: completely processed by multibeam and at HPSS\n";
+          }
+        else {
+          $moveto = "./_TO_BE_DELETED";
+          if (! (-f "${file}.completely_done_ap" ||
+                 -f "${file}.completely_done_with_errors_ap") ) { 
+            $message .= "${file}: astropulse not yet finished processing\n";
+            $domove = 0;
+            }
+          else {
+            # if (-f "${file}.completely_done_with_errors_ap") { $moveto = "./_COMPLETELY_DONE_WITH_ERRORS"; }
+            if (-f "${file}.completely_done_with_errors_ap") { $moveto = "./_TO_BE_DELETED"; }
+            }
+          if (! (-f "${file}.completely_done" ||
+                 -f "${file}.completely_done_with_errors") ) { 
+            $message .= "${file}: multibeam not yet finished processing\n";
+            $domove = 0;
+            }
+          else {
+            # if (-f "${file}.completely_done_with_errors") { $moveto = "./_COMPLETELY_DONE_WITH_ERRORS"; }
+            if (-f "${file}.completely_done_with_errors") { $moveto = "./_TO_BE_DELETED"; }
+            }
+          if ($domove == 1) {
+            $thisdate = `/bin/date "+%F-%T"`;
+            chomp $thisdate;
+            if (-f "${file}.completely_done") { system ("/bin/mv ${file}.completely_done ./_COMPLETELY_DONE_HISTORY/${file}.completely_done.${thisdate}"); }
+            if (-f "${file}.completely_done_ap") { system ("/bin/mv ${file}.completely_done_ap ./_COMPLETELY_DONE_HISTORY/${file}.completely_done_ap.${thisdate}"); }
+            if (-f "${file}.completely_done_with_errors") { system ("/bin/mv ${file}.completely_done_with_errors ./_COMPLETELY_DONE_HISTORY/${file}.completely_done_with_errors.${thisdate}"); }
+            if (-f "${file}.completely_done_with_errors_ap") { system ("/bin/mv ${file}.completely_done_with_errors_ap ./_COMPLETELY_DONE_HISTORY/${file}.completely_done_with_errors_ap.${thisdate}"); }
+            system ("/bin/mv ${file} $moveto");
+            system ("/bin/mv ${file}.* $moveto");
+            $message .= "${file}: astropulse/multibeam completely done and at HPSS - moved into $moveto\n";
+            } # end if $domove == 1
+          } # end if $check_only == 1
+        } # end if $domove = 1
+      } # end if file completely done
+    else {
+      $message .= "${file}: not finished processing/xfering to hpss yet\n";
+      if (! (-f "${file}.completely_done" || -f "${file}.completely_done_with_errors") ) {
+        $message .= "    ${file}: multibeam not yet finished processing\n";
+        }
+      if (! (-f "${file}.completely_done_ap" || -f "${file}.completely_done_with_errors_ap") ) {
+        $message .= "    ${file}: astropulse not yet finished processing\n";
+        }
+      if (! (-f "${file}.at_hpss")) {
+        $message .= "    ${file}: no .at_hpss file - not finished xfering?\n";
+        }
+      }
+    }
+  }
+
+
+# only bother with the actual file deleting if check_only == 0 && not_at_hpss == 0
+
+if ($not_at_hpss == 1) { exit (0); }
+
+if ($check_only == 0) {
+
+  if ($message ne "") { $message .= "\n"; } # if needed skip a line in case there's more
+  
+  chdir "./_TO_BE_DELETED";
+  undef @del_file_list;
+  open (LS,"/bin/ls . |");
+  while (<LS>) {
+    $thisfile = $_; chomp $thisfile;
+    if (/^[0-9][0-9][a-z][a-z][0-9][0-9][a-z][a-z]$/) { push @del_file_list, $_ }
+    }
+  close (LS);
+  chomp @del_file_list;
+  
+  foreach $del_file (@del_file_list) {
+    if (-l $del_file) {
+      $message .= "${del_file}: is a symbolic link.. skipping..\n";
+      }
+    else {
+      $cdmtime = (stat("${del_file}.completely_done"))[9];
+      $ahmtime = (stat("${del_file}.at_hpss"))[9];
+      # print "${del_file} $cdmtime $ahmtime\n";
+      $now = time();
+      if (($now - $cdmtime) > $keep_for && ($now - $ahmtime) > $keep_for) {
+        system ("/bin/rm -f ${del_file}*");
+        $cdmdelta = ($now - $cdmtime);
+        $ahmdelta = ($now - $ahmtime);
+        $message .= "${del_file}: finished splitting $cdmdelta seconds ago, copied to HPSS $ahmdelta seconds ago - deleting!\n";
+        }
+      }
+    }
+
+  }
+
+# send mail!
+
+if ($message ne "") {  
+  open(MAIL, "|/usr/sbin/sendmail -tv");
+  print MAIL "To: ${email_list}\n";
+  print MAIL 'From: seti at ssl.berkeley.edu' . "\n";
+  print MAIL "Subject: splitter_janitor report\n\n";
+  print MAIL "$message";
+  close(MAIL);
+  }
+
+exit (0);
diff --git a/splitter_pfb/mb_read_blocks_dr2.cpp b/splitter_pfb/mb_read_blocks_dr2.cpp
index ba75d75..9c4ab54 100644
--- a/splitter_pfb/mb_read_blocks_dr2.cpp
+++ b/splitter_pfb/mb_read_blocks_dr2.cpp
@@ -31,9 +31,11 @@ int read_blocks_dr2(int   tape_fd,
         }
     }
 
+//fprintf(stderr, "in read_blocks_dr2 : tapebuffer size is %ld num_blocks_to_read %d\n", (long)tapebuffer.size(), num_blocks_to_read);
     num_blocks_read = seti_StructureDr2Data(tape_fd, beam, pol,
                                             num_blocks_to_read,       
                                             tapebuffer, blanker_filter);
+//fprintf(stderr, "in read_blocks_dr2 : tapebuffer size is %ld data is %ld\n", (long)tapebuffer.size(), tapebuffer[0].data.size());
     while (num_blocks_read == num_blocks_to_read) {
         //check for an uninterrupted run
         if (valid_run(tapebuffer,splitter_settings.receiver_cfg->min_vgc)) {
@@ -61,7 +63,7 @@ int read_blocks_dr2(int   tape_fd,
 }
 
 //-------------------------------------------------------------------------
-int find_start_point_dr2(int tape_fd, int beam, int pol) {
+int find_start_point_dr2(int tape_fd, int beam, int pol, int beamchan) {
 //-------------------------------------------------------------------------
   char buf[1024];
 
@@ -106,7 +108,8 @@ int find_start_point_dr2(int tape_fd, int beam, int pol) {
     tape thistape;
     thistape.id=0; 
     readbytes=HeaderSize;
-    sprintf(buf,"%d",rcvr.s4_id-AO_ALFA_0_0);
+    //sprintf(buf,"%d",rcvr.s4_id-AO_ALFA_0_0);
+    sprintf(buf,"%d",beamchan);
     if (thistape.fetch(std::string("where name=\'")+header.name+"\' and beam="+buf)) {
       log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG,"Resuming tape %s beam %d pol %d\n",thistape.name,beam,pol );
       while ((readbytes==HeaderSize) && (header.dataseq!=thistape.last_block_done)) {
diff --git a/splitter_pfb/mb_read_blocks_dr2.h b/splitter_pfb/mb_read_blocks_dr2.h
index f1a6364..696e2de 100644
--- a/splitter_pfb/mb_read_blocks_dr2.h
+++ b/splitter_pfb/mb_read_blocks_dr2.h
@@ -4,4 +4,4 @@ int read_blocks_dr2(int   tape_fd,
                     int   beam,
                     int   pol,
                     int   vflag);
-int find_start_point_dr2(int tape_fd, int beam, int pol);
+int find_start_point_dr2(int tape_fd, int beam, int pol, int beamchan);
diff --git a/splitter_pfb/mb_read_blocks_guppi.cpp b/splitter_pfb/mb_read_blocks_guppi.cpp
index 1dbf8ab..5a005b1 100644
--- a/splitter_pfb/mb_read_blocks_guppi.cpp
+++ b/splitter_pfb/mb_read_blocks_guppi.cpp
@@ -41,10 +41,12 @@
 //
 #if 0
 
-struct gpu_input {
+We read the actual data samples ass pointed to by rawinput.pf.sub.data
+
+struct gpu_input {                                                              // this is instantiated as rawdata
     char *file_prefix;
     struct                  guppi_params gf;
-    struct                  psrfits pf;
+    struct                  psrfits pf;                                         // path to data : rawdata.pf
     unsigned int filecnt;
     FILE *fil;
     int invalid;
@@ -64,7 +66,7 @@ struct guppi_params {
 struct psrfits {
     char mode;              // Read (r) or write (w).
     struct                  hdrinfo hdr;
-    struct                  subint sub;
+    struct                  subint sub;                                         // path to data : rawdata.pf.sub
 };
 
 struct hdrinfo {
@@ -85,21 +87,29 @@ struct subint {
     double ra;              // RA (J2000) at subint centre (deg)
     double dec;             // Dec (J2000) at subint centre (deg)
     int bytes_per_subint;   // Number of bytes for one row of raw data
-    unsigned char *data;    // Ptr to the raw data itself
+    unsigned char *data;    // Ptr to the raw data itself                       // path to data : rawdata.pf.sub.data
 };
 
 #endif
 
+unsigned long total_samples = 0;
+unsigned long limit_samples;
+unsigned long last_num_samples_read;
+
 #define RAW_DATA_HEADER_BUF_SIZE 32768
+//#define RAW_DATA_HEADER_BUF_SIZE 8192         // TODO would it help to do less reading/rewinding for each header?
 
 typedef struct {
     // file control...
     long long int   startindx;
     long long int   curindx;
-	long long int   chanbytes;
+	long long int   chanbytes;      // = control_block.indxstep * rawinput.gf.packetsize / (8/raw_bit_depth * rawinput.pf.hdr.nchan); 
 	long long int   subint_offset;
 	long int        currentblock;
-	int             indxstep;
+	int             indxstep;       // = (int) ((rawinput.pf.sub.bytes_per_subint * samples_per_byte) / rawinput.gf.packetsize) - 
+                                    //   (int) (rawinput.overlap * rawinput.pf.hdr.nchan * rawinput.pf.hdr.rcvr_polns           * 
+                                    //   2 / rawinput.gf.packetsize);
+    int             last_block_done;
     // user prefs...
     int             channel;
     int             polarization;
@@ -117,14 +127,15 @@ extern void guppi_read_obs_params(char *buf,
 
 int exists(const char *fname);
 
-int unpack_samples(unsigned char * raw, long int count, int pol, dr2_compact_block_t &this_tapebuffer);
+unsigned long unpack_samples(unsigned char * raw, long int count, int pol, dr2_compact_block_t &this_tapebuffer);
 
 //-------------------------------------------------------
-int print_header(dr2_compact_block_t &this_tapebuffer) {
+void print_header(dr2_compact_block_t &this_tapebuffer) {
 //-------------------------------------------------------
 
-	fprintf(stderr, "setiheader : Name: %s Header Size: %d Data Size: %d Channel: %d Polarization: N samplerate %lf sky_freq %ld Data Time: %lf Coordinate Time: %lf RA: %f Dec: %f\n", 
+	fprintf(stderr, "setiheader : Name: %s Frontend: %s Header Size: %d Data Size: %d Channel: %d Polarization: N samplerate %lf sky_freq %ld Data Time: %lf Coordinate Time: %lf RA: %f Dec: %f\n", 
             this_tapebuffer.header.name,
+            this_tapebuffer.header.frontend,
             this_tapebuffer.header.header_size,
 	        this_tapebuffer.header.data_size,		
 	        this_tapebuffer.header.channel,		
@@ -137,7 +148,8 @@ int print_header(dr2_compact_block_t &this_tapebuffer) {
 }
 
 //-------------------------------------------------------
-int populate_header(
+void populate_header(
+                char                *file_prefix,
 	            control_block_t     &control_block,
                 struct gpu_input    &rawinput,
                 dr2_compact_block_t &this_tapebuffer
@@ -147,21 +159,24 @@ int populate_header(
     /* size of this header */
     this_tapebuffer.header.header_size = sizeof(this_tapebuffer.header);
 
-    /* number of samples * size of a signed char * 2 for real/imag */
-    this_tapebuffer.header.data_size = (control_block.chanbytes * sizeof(signed char) * 2);
-
     /* populate with source name from psrfits header */
-    sprintf(this_tapebuffer.header.name, "%s", rawinput.pf.hdr.source);
+    strncpy(this_tapebuffer.header.name, basename(file_prefix), sizeof(this_tapebuffer.header.name));
+
+    /* populate with frontend name from psrfits header */
+    strncpy(this_tapebuffer.header.frontend, rawinput.pf.hdr.frontend, sizeof(this_tapebuffer.header.frontend));
 
     /* populate channel and polarization */
     this_tapebuffer.header.channel      = control_block.channel;
-    //this_tapebuffer.header.polarization = control_block.polarization;   // TODO add polarization
+    // this_tapebuffer.header.polarization = control_block.polarization;   // TODO add polarization
 
-    /* (complex) sample rate in Hz */
-    this_tapebuffer.header.samplerate = rawinput.pf.hdr.df * 1000000;
+    /* (complex) sample rate in MHz */
+    this_tapebuffer.header.samplerate = rawinput.pf.hdr.df;
+
+    /* there is no "dataseq in guppi data.  TODO - right? */
+    //this_tapebuffer.header.dataseq = 0;
 
     this_tapebuffer.header.sky_freq =   (long int) (
-                              (double) 1000000 * 
+                              (double) 1e6 * 
                               ( 
                                 (rawinput.pf.hdr.fctr   - 
                                 (rawinput.pf.hdr.BW/2)) + 
@@ -178,8 +193,7 @@ int get_params(
 	            control_block_t     &control_block,
                 struct gpu_input    &rawinput,
                 char                header_buf[],
-                char                filname[],
-	            unsigned char *     &channelbuffer	
+                char                filname[]
 ) {
 //-------------------------------------------------------
 	long long int chanbytes_overlap = 0;
@@ -187,12 +201,13 @@ int get_params(
 	    if(fread(header_buf, sizeof(char), RAW_DATA_HEADER_BUF_SIZE, rawinput.fil) == RAW_DATA_HEADER_BUF_SIZE){
 		   
 		    guppi_read_obs_params(header_buf, &rawinput.gf, &rawinput.pf);
-		   
-            // Get to first 2 bit data header...
-            // At regular intervals, as a sanity check, the 2 bit
+
+            // Get to first N bit data header where N != 8...
+            // At regular intervals, as a sanity check, the N bit
             // data are preceeded by the full 8 bit version of
             // the same data.  We ignore the 8 bit data here.
-		    if(rawinput.pf.hdr.nbits == 8) {
+            // We ignore this whole check if we have 8 bit data.
+		    if(raw_bit_depth != 8 && rawinput.pf.hdr.nbits == 8) {
 			    fprintf(stderr, "caught an 8 bit header... moving on to first/next 2 bit header\n");
 			    /* figure out the size of the first subint + header */
 		        rawinput.first_file_skip = rawinput.pf.sub.bytes_per_subint + gethlength(header_buf);
@@ -215,12 +230,13 @@ int get_params(
 
 		    hgeti4(header_buf, "OVERLAP", &rawinput.overlap);
 			
-		    fprintf(stderr, "   packetindex       : %lld\n", rawinput.gf.packetindex);
+		    fprintf(stderr, "   pktindx           : %lld\n", rawinput.gf.packetindex);
 		    fprintf(stderr, "   packetsize        : %d\n", rawinput.gf.packetsize);
 		    fprintf(stderr, "   n_packets         : %d\n", rawinput.gf.n_packets);
 		    fprintf(stderr, "   n_dropped         : %d\n",rawinput.gf.n_dropped);
 		    fprintf(stderr, "   bytes_per_subint  : %d\n",rawinput.pf.sub.bytes_per_subint);
 		    fprintf(stderr, "   overlap           : %d\n",rawinput.overlap);
+		    fprintf(stderr, "   bit depth         : %d\n",raw_bit_depth);
 	        } else {    
 	  		    fprintf(stderr, "couldn't read a header\n");
 			    return 0;
@@ -230,14 +246,16 @@ int get_params(
     if(control_block.vflag>=1) fprintf(stderr, "calculating index step\n");
 
     /* number of packets that we *should* increment by */
-    control_block.indxstep = (int) ((rawinput.pf.sub.bytes_per_subint * 4) / rawinput.gf.packetsize)              - 
+    //control_block.indxstep = (int) ((rawinput.pf.sub.bytes_per_subint * 4) / rawinput.gf.packetsize) - 
+    control_block.indxstep = (int) ((rawinput.pf.sub.bytes_per_subint * samples_per_byte) / rawinput.gf.packetsize) - 
                       (int) (rawinput.overlap * rawinput.pf.hdr.nchan * rawinput.pf.hdr.rcvr_polns  * 
                       2 / rawinput.gf.packetsize);
 
-    //spectraperint = control_block.indxstep * band[first_good_band].gf.packetsize / (band[first_good_band].pf.hdr.nchan * band[first_good_band].pf.hdr.rcvr_polns * 2 * ftacc);
-    //spectraperint = ((rawinput.pf.sub.bytes_per_subint / rawinput.pf.hdr.nchan) - rawinput.overlap) / ftacc;	
-
-    //overlap = rawinput.overlap;
+    if(control_block.vflag>=1) {
+        fprintf(stderr, "index step %d bytes_per_subint %d packetsize %d overlap %d nchan %d rcr_polns %d\n",
+                control_block.indxstep, rawinput.pf.sub.bytes_per_subint, rawinput.gf.packetsize,
+                rawinput.overlap, rawinput.pf.hdr.nchan, rawinput.pf.hdr.rcvr_polns);
+    }
 
     if (control_block.channel >= rawinput.pf.hdr.nchan) {
 	    fprintf(stderr, "control_block.channel %d more than channels in data %d\n", control_block.channel, rawinput.pf.hdr.nchan);
@@ -249,33 +267,12 @@ int get_params(
     /* number of non-overlapping bytes in each channel */
     /* control_block.indxstep increments by the number of unique packets in each sub-integration */
     /* packetsize is computed based on the original 8 bit resolution */
-    /* divide by 4 to get to 2 bits, nchan to get to number of channels */
-
-    control_block.chanbytes = control_block.indxstep * rawinput.gf.packetsize / (4 * rawinput.pf.hdr.nchan); 
+    /* divide by 8/raw_bit_depth to get to 2 or 8 bits, nchan to get to number of channels */
+    // TODO - this needs to change for 8 bit data!!
+    //control_block.chanbytes = control_block.indxstep * rawinput.gf.packetsize / (4 * rawinput.pf.hdr.nchan); 
+    control_block.chanbytes = control_block.indxstep * rawinput.gf.packetsize / (8/raw_bit_depth * rawinput.pf.hdr.nchan); 
     fprintf(stderr, "chan bytes %lld\n", control_block.chanbytes);
 
-    // commented out by jeffc - channelbuffer is unused 
-    //channelbuffer  = (unsigned char *) calloc( control_block.chanbytes , sizeof(char) );
-    //if (!channelbuffer) {
-	//    fprintf(stderr, "error: couldn't allocate memory for buffer\n");
-	//    return 0;
-    //}
-
-    //fprintf(stderr, "malloc'ed %Ld bytes for channel %d\n",  control_block.chanbytes, control_block.channel );	
-
-    //	tstart=band[first_good_band].pf.hdr.MJD_epoch;
-    //	tsamp = band[first_good_band].pf.hdr.dt * ftacc;
-
-    //	strcat(buf, strtok(band[first_good_band].pf.hdr.ra_str, ":"));
-    //	strcat(buf, strtok(band[first_good_band].pf.hdr.dec_str, ":"));
-
-    /*
-    fprintf(stderr, "freq %ld\n", setiheader.sky_freq);
-    fprintf(stderr, "fctr %lf\n", rawinput.pf.hdr.fctr);
-    fprintf(stderr, "bandwidth %lf\n", rawinput.pf.hdr.BW);
-    fprintf(stderr, "freqdouble %lf\n", ((double) 1000000 * ((rawinput.pf.hdr.fctr - (rawinput.pf.hdr.BW/2)) + ((control_block.channel+0.5) * rawinput.pf.hdr.df))));
-    */
-
     /* total number of bytes per channel, including overlap */
     chanbytes_overlap = rawinput.pf.sub.bytes_per_subint / rawinput.pf.hdr.nchan;
 
@@ -295,7 +292,7 @@ int read_block(
                 char                filname[],
                 double              &start_data_time,
                 double              &end_data_time,
-                long int            file_cnt,
+                long int            filecnt,
                 dr2_compact_block_t &this_tapebuffer
 ) {
 //-------------------------------------------------------
@@ -316,21 +313,24 @@ int read_block(
 			  	    rawinput.invalid = 1;
 		  	  	    fprintf(stderr, "couldn't open any more files!\n");
 		  	    }
-		    }
+		    }  // end  if(rawinput.fil == NULL)
 
 		    if(rawinput.fil){		  
-		        fprintf(stderr, "Reading first/next 32KB\n"); 
-	            //if((fread(buf, sizeof(char), RAW_DATA_HEADER_BUF_SIZE, rawinput.fil) == RAW_DATA_HEADER_BUF_SIZE) && (control_block.currentblock < (control_block.numblocks + control_block.startblock - 1)) ) {				
+		        fprintf(stderr, "Reading %ld bytes - more than enough to obtain first/next header (we'll rewind)\n", RAW_DATA_HEADER_BUF_SIZE); 
 	            if(fread(header_buf, sizeof(char), RAW_DATA_HEADER_BUF_SIZE, rawinput.fil) == RAW_DATA_HEADER_BUF_SIZE) {
-		            fprintf(stderr, "...success!\n"); 
-					fseek(rawinput.fil, -RAW_DATA_HEADER_BUF_SIZE, SEEK_CUR);                                  // reposition to the start of this 32KB
+		            //fprintf(stderr, "...success!\n"); 
+					fseek(rawinput.fil, -RAW_DATA_HEADER_BUF_SIZE, SEEK_CUR);           // rewind for (header plus) data read
+
 					if(control_block.vflag>=1) fprintf(stderr, "header length: %d\n", gethlength(header_buf));
+
+                    // parse the header we just read
 					guppi_read_obs_params(header_buf, &rawinput.gf, &rawinput.pf);
 
+                    // get our current block number 
 					control_block.currentblock = (long int) ((double) rawinput.gf.packetindex/ (double) control_block.indxstep);
 
 					if(control_block.vflag>=1) {
-						 fprintf(stderr, "packetindex %Ld packetsize: %d n_packets %d n_dropped: %d blocks: %ld RA: %f DEC: %f subintoffset %f tsubint %f MJD %Lf\n", 
+						 fprintf(stderr, "pktindx %Ld packetsize: %d n_packets %d n_dropped: %d blocks: %ld RA: %f DEC: %f subintoffset %f tsubint %f MJD %Lf\n", 
                                     rawinput.gf.packetindex,
 						            rawinput.gf.packetsize,
 						            rawinput.gf.n_packets,
@@ -342,9 +342,11 @@ int read_block(
 						            rawinput.pf.sub.tsubint,
 						            rawinput.pf.hdr.MJD_epoch);
 					}
+
 					
 					/* populate the variables that change with each block */
 				    /* RA (J2000) at subint centre (deg), Dec (J2000) at subint centre (deg), time in MJD */
+                    this_tapebuffer.header.dataseq      = control_block.currentblock;
 					this_tapebuffer.header.ra           = rawinput.pf.sub.ra/15.0;      // splitter expects RA in decimal hours            
 					this_tapebuffer.header.dec          = rawinput.pf.sub.dec;           
 					/* increment time for data by 0.5 x length of block to push quoted time to the _last_ sample in the block */					
@@ -359,38 +361,52 @@ int read_block(
                         end_data_time = this_tapebuffer.header.data_time.mjd().uval();     // assigned many times, will end up with the final block's time
                     }
 					
-			   		if(rawinput.gf.packetindex == control_block.curindx) {
-						 /* read a subint with correct index */
+			   		if(rawinput.gf.packetindex == control_block.curindx) {    // file integrity check - are we at the correct index?  Yes...
 
-						 fseek(rawinput.fil, gethlength(header_buf), SEEK_CUR);
+						 fseek(rawinput.fil, gethlength(header_buf), SEEK_CUR);         // skip past header
 						 rv=0;
 						 
-						 if (control_block.currentblock > (control_block.startblock-1)){
+						 if (control_block.currentblock > (control_block.startblock-1)){   // if we have reached user requested startblock (default 0)
 						 
-						 	rv=fread(rawinput.pf.sub.data, sizeof(char), rawinput.pf.sub.bytes_per_subint, rawinput.fil);  // read raw samples		 
+                            // read raw data.  bytes_per_subint should == BLOCSIZE value from header
+						 	rv=fread(rawinput.pf.sub.data, sizeof(char), rawinput.pf.sub.bytes_per_subint, rawinput.fil); 
 						 	
-							if( ((long int)rv == rawinput.pf.sub.bytes_per_subint) ){
-							   if(control_block.vflag>=1) fprintf(stderr,"read %d bytes from %ld in curfile %d\n", 
-                                                                  rawinput.pf.sub.bytes_per_subint, file_cnt, rawinput.curfile);						
-							   unpack_samples(rawinput.pf.sub.data + control_block.subint_offset, 
-                                              control_block.chanbytes, 
-                                              control_block.polarization,
-                                              this_tapebuffer);   					               // unpack samples to the return vector   
-
-                               // The following two lines were commented out in Andrews code.
-							   //memcpy(channelbuffer + channelbuffer_pos, rawinput.pf.sub.data + control_block.subint_offset, control_block.chanbytes);										   
-							   //channelbuffer_pos = channelbuffer_pos + control_block.chanbytes;
+							if( ((long int)rv == rawinput.pf.sub.bytes_per_subint) ){       // if we got the expected amount of raw data
+                               long filepos = ftell(rawinput.fil);							   
+                               if(control_block.vflag>=1) {
+                                    fprintf(stderr,"read %d bytes starting at filepos %ld in file %ld of %d ... chanbytes is %d\n", 
+                                            rawinput.pf.sub.bytes_per_subint, filepos, rawinput.curfile, filecnt, control_block.chanbytes);						
+                                    }
+                               // wrap unpacking samples in restart logic.  We skip the unpack (but do everything else) if we are not
+                               // to the point of resumption.
+                               if(control_block.currentblock >= control_block.last_block_done) {
+                                    //if(control_block.vflag>=1) fprintf(stderr, "prior to unpack_samples : last : %ld total : %ld\n", 
+                                    //                                   last_num_samples_read, total_samples);
+						            last_num_samples_read = unpack_samples(rawinput.pf.sub.data     +   // start of raw data, ie channel 0
+                                                                           control_block.subint_offset, // this gets us to the requested channel 
+                                                                           control_block.chanbytes,     // chanbytes does not include overlap
+                                                                           control_block.polarization,
+                                                                           this_tapebuffer);   			// unpack samples to the return vector   
+                                    if(control_block.vflag>=1) fprintf(stderr, "Just unpacked %ld samples from %ld bytes.  Total samples : %ld\n", 
+                                                                       last_num_samples_read, control_block.chanbytes, total_samples);
+                               } else {
+                                    log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG,"Not to point of resumption (%ld < %ld), skipping...\n", 
+                                                        control_block.currentblock, control_block.last_block_done);
+                               }  // end of unpack with restart logic
 
 							} else {
 								rawinput.fil = NULL;
 								rawinput.invalid = 1;
 								fprintf(stderr,"ERR: couldn't read as much as the header said we could... assuming corruption and exiting...\n");
-								return 0;
-							}
+								exit(1);
+							}  // end if we got the expected amount of raw data
 
-						 } else (rv = fseek(rawinput.fil, rawinput.pf.sub.bytes_per_subint, SEEK_CUR)); 
+						 } else {                                                                   // we have not reached the requested startblock
+                            (rv = fseek(rawinput.fil, rawinput.pf.sub.bytes_per_subint, SEEK_CUR)); // ... so seek to the next block
+                         }  // end if we have reached user requested startblock
 						 
 					} else if( (rawinput.gf.packetindex > control_block.curindx) && (control_block.currentblock > (control_block.startblock-1)) ) {
+                         // are we at the correct index?  No, we apparently dropped a subintegration.  This is correctable...
 
 						 fprintf(stderr,"ERR: control_block.curindx: %Ld, pktindx: %Ld Did we drop a whole subintegration? Reusing last subint...\n", 
                                  control_block.curindx, rawinput.gf.packetindex );
@@ -419,16 +435,17 @@ int read_block(
 						/* We'll get the current valid subintegration again on the next time through this loop */
 
 					} else if(rawinput.gf.packetindex < control_block.curindx) {
+                         // are we at the correct index?  No, nor have we dropped a subintegration.  This is a file integrity fatal error...
 						 fprintf(stderr,"Error expecting a higher packet index than we got control_block.curindx: %Ld, pktindx: %Ld\n", 
                                  control_block.curindx, rawinput.gf.packetindex );
 						 /* somehow we were expecting a higher packet index than we got !?!? */	
 						 fprintf(stderr, "assuming corruption and exiting...\n");
-						 return(0);
-					}
+						 exit(1);
+					}  // end are we at the correct index
     
                 if(control_block.vflag>=1) fprintf(stderr, "Read block %ld\n", control_block.currentblock);
-                //if(control_block.vflag>=1) {print_header_old(setiheader); print_header(this_tapebuffer);}
-                if(control_block.vflag>=1) print_header(this_tapebuffer);
+
+                //if(control_block.vflag>=1) print_header(this_tapebuffer);
                 retval = true;
 				} else {
 				   fprintf(stderr, "Could not read first/next 32KB\n"); 
@@ -441,83 +458,67 @@ int read_block(
 	    }   // end if(!rawinput.invalid)
 										
 	    if(rawinput.fil != NULL) {
+            //fprintf(stderr, "index step : %d\n", control_block.indxstep);
             control_block.curindx = control_block.curindx + control_block.indxstep;
-            retval = 1;     // we have a new block
+            retval = 1;     // we have a new block, which may be empty if we are fast forwarding to the point of resumption
         } else {
-            retval = 0;     // we do not have a new block
+            retval = 0;     // we do not have a new block. Perhaps we just need to open the next file in the series.
         }
 
+    //if(control_block.vflag>=1) fprintf(stderr, "last_num_samples_read %ld chanbytes %ld\n", last_num_samples_read, control_block.chanbytes);
     return(retval);
 }
 
 //-------------------------------------------------------
-long int read_blocks_guppi(char *           file_prefix,
-                           long int         startblock, 
-                           long int         numblocks, 
-                           int              channel, 
-                           int              polarization, 
-                           int              vflag 
+int init(
+                char *              file_prefix,
+                long int            startblock, 
+                int                 channel, 
+                int                 polarization, 
+                int                 vflag, 
+	            control_block_t     &control_block,
+                struct gpu_input    &rawinput,
+                char                header_buf[],
+                char                filname[],
+                double              &start_data_time,
+                double              &end_data_time,
+                int                 &filecnt,
+                dr2_compact_block_t &this_tapebuffer
 ) {
 //-------------------------------------------------------
 
-	int overlap; // amount of overlap between sub integrations in samples
-
-    int retval=0;
-
-	int filecnt=0;
-    char header_buf[RAW_DATA_HEADER_BUF_SIZE];   // we read the raw data headers into this buffer
-
-	unsigned char *channelbuffer;	
-
-	char filname[250];
-
-    dr2_compact_block_t this_tapebuffer;
-
-	struct gpu_input rawinput;	
-
-    control_block_t control_block;
+    rawinput.file_prefix        =file_prefix;
+    rawinput.fil                = NULL;
+    rawinput.invalid            = 0;
+	rawinput.first_file_skip    = 0;  
+    //control_block.check_last    = 1;
     control_block.chanbytes     = 0;
     control_block.subint_offset = 0;
     control_block.currentblock  = 0;
     control_block.indxstep      = 0;
     control_block.channel       = channel;
     control_block.polarization  = polarization;
-    control_block.numblocks     = numblocks;
+    //control_block.numblocks     = numblocks;
     control_block.startblock    = startblock;
     control_block.vflag         = vflag;
 
-    size_t rv=0;
-	long unsigned int by=0;
-	long int i=0,j=0;
-
-    double start_data_time;
-    double end_data_time;
-
-	rawinput.file_prefix = NULL;
-	rawinput.fil = NULL;
-	rawinput.invalid = 0;
-	rawinput.first_file_skip = 0;  
-
-    opterr = 0;
-    rawinput.file_prefix=file_prefix;
-     
-    /* no input specified */
     if(rawinput.file_prefix == NULL) {
-	    printf("WARNING no input stem specified%ld\n", (i+1));
-	    return 0;
+	    printf("ERR no input stem specified, exiting...\n");
+	    exit(1);
     }
 
     if(strstr(rawinput.file_prefix, ".0000.raw") != NULL) memset(rawinput.file_prefix + strlen(rawinput.file_prefix) - 9, 0x0, 9);
 
     // get size of data set, in terms of file count and byte count
     fprintf(stderr, "Finding size of data set...\n");
-    j = 0;
+    //j = 0;
     struct stat st;
     long int size=0;
+	long int i=0;
     do {
-	    sprintf(filname, "%s.%04ld.raw",rawinput.file_prefix,j);
+	    sprintf(filname, "%s.%04ld.raw",rawinput.file_prefix,i);
 	    fprintf(stderr, "  trying %s ...",filname);		
-	    j++;
+	    i++;
 	    if(exists(filname)) { 
             fprintf(stderr, " found\n");
 		    stat(filname, &st);
@@ -526,12 +527,12 @@ long int read_blocks_guppi(char *           file_prefix,
             fprintf(stderr, " not found\n");
         }
     } while (exists(filname));
-    rawinput.filecnt = j-1;
-    fprintf(stderr, "  File count is %i  Total size is %ld bytes\n",rawinput.filecnt, size);
+    rawinput.filecnt = i-1;
+    fprintf(stderr, "  File count is %i  Total data set size is %ld bytes\n",rawinput.filecnt, size);
 
-    /* didn't find any files */
+   /* didn't find any files */
     if(rawinput.filecnt < 1) {
-	    fprintf(stderr, "no files for stem %s found\n",rawinput.file_prefix);
+	    fprintf(stderr, "no files for stem %s found, exiting...\n",rawinput.file_prefix);
 	    exit(1);		
     }
 
@@ -548,13 +549,12 @@ long int read_blocks_guppi(char *           file_prefix,
                 control_block,
                 rawinput,
                 header_buf,
-                filname,
-                channelbuffer
+                filname
     );
 
     // Now that we know our sizing requirements, allocate the buffers...
-    // ...raw data read buffer (allocate and free each time because we don 't know 
-    // how many times we'll be here)
+    // TODO - we should explicitly free this memory even though we allocate
+    // once and need it until program exit.
     rawinput.pf.sub.data  = (unsigned char *) malloc(rawinput.pf.sub.bytes_per_subint);
     if(!rawinput.pf.sub.data) {
 	    fprintf(stderr, "error: couldn't allocate memory for the raw data read buffer\n");
@@ -565,20 +565,154 @@ long int read_blocks_guppi(char *           file_prefix,
 
     // populate the header with static items
     populate_header(
+                rawinput.file_prefix,
 	            control_block,
                 rawinput,
                 this_tapebuffer
     );
 
-    //fflush(stdout);
-
     control_block.startindx        = rawinput.gf.packetindex;
     control_block.curindx          = control_block.startindx;
     filecnt                        = rawinput.filecnt;
     rawinput.curfile               = 0;			
 
-    // Read blocks until we run out of data or the numblocks request is met
+    return 1;   // success
+}
+
+//-------------------------------------------------------
+void dump_tapebuffer(char * file_prefix, int channel) {
+//-------------------------------------------------------
+
+        FILE * dump_fp;
+        char dump_fn[256];
+        sprintf(dump_fn, "%s%s%d", basename(file_prefix), ".tapebuffer_dump.channel_", channel);
+        dump_fp = fopen(dump_fn, "w");
+        if(dump_fp == NULL) {
+             fprintf(stderr, "could not open dump file %s, exiting...", dump_fn);
+                exit(1);
+        }
+        for(int buffer_i=0; buffer_i < tapebuffer.size(); buffer_i++) {
+            for(int buffer_j=0; buffer_j < tapebuffer[buffer_i].data.size(); buffer_j++) {
+                fwrite((const void *)&tapebuffer[buffer_i].data[buffer_j].real(), 1, 1, dump_fp);
+                fwrite((const void *)&tapebuffer[buffer_i].data[buffer_j].imag(), 1, 1, dump_fp);
+            }
+        }
+        fclose(dump_fp);
+}
+
+
+
+//-------------------------------------------------------
+long int read_blocks_guppi(char *           file_prefix,
+                           long int         startblock, 
+                           long int         numsamples, 
+                           int              channel, 
+                           int              polarization, 
+                           int              vflag 
+) {
+//-------------------------------------------------------
+
+    int retval = 0;
+    static bool first_time = true;
+
+    char header_buf[RAW_DATA_HEADER_BUF_SIZE];   // we read the raw data headers into this buffer
+
+    long reent_total_samples = 0;
+
+    static unsigned long samples_left;
+    static double start_data_time;
+    static double end_data_time;
+	static int filecnt;
+	static char filname[250];
+    static dr2_compact_block_t this_tapebuffer;
+	static struct gpu_input rawinput;	
+    static control_block_t control_block;
+
+    limit_samples = numsamples;                 // TODO - this should go into the control block
+    total_samples = 0;
+     
+    if(first_time) {
+        first_time = false;
+        retval = init(
+                    file_prefix,
+                    startblock,
+                    channel,
+                    polarization,
+                    vflag,                
+                    control_block,
+                    rawinput,
+                    header_buf,
+                    filname,
+                    start_data_time,
+                    end_data_time,
+                    filecnt,
+                    this_tapebuffer
+                 );
+        if(retval == 0) return(0);
+        if (resumetape) {
+            char * filename = basename(rawinput.file_prefix);
+            tape thistape;
+            thistape.id=0; 
+            char beambuf[16];
+            sprintf(beambuf,"%d", 2*channel+polarization);            
+            if (thistape.fetch(std::string("where name=\'")+filename+"\' and beam="+beambuf)) {
+                control_block.last_block_done = thistape.last_block_done;
+                log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG,
+                                    "Resuming tape %s channel %d pol %d at block %d\n",
+                                    thistape.name,channel,polarization,control_block.last_block_done);
+            } else {
+                log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG,
+                                    "Cannot resume : tape %s channel %d pol %d beam %s not found.  Starting at the beginning.\n",
+                                    filename,channel,polarization, beambuf);
+                //return(0);
+            }
+        }  // end if(resumetape)
+    } else {    // not first time -  on subsequent calls we need to account for splitter (not guppi) overlap
+        reent_total_samples = 0;
+        for(int buffer_i=0; buffer_i < tapebuffer.size(); buffer_i++) {
+            reent_total_samples += tapebuffer[buffer_i].data.size();
+            if(control_block.vflag>=2) {
+                fprintf(stderr, "re-entry - tapebuffer %d has %ld samples\n", buffer_i, tapebuffer[buffer_i].data.size());
+            }
+        }
+        total_samples = reent_total_samples;        // starting this call with thais many samples :
+        if(control_block.vflag>=2) {
+            fprintf(stderr, "re-entry - total_samples = %ld (%ld) in %ld tapebuffers\n", reent_total_samples, total_samples, tapebuffer.size());
+        }
+    }  // end first/subsequent time logic 
+
+
+    // take care of any samples left over in the guppi buffer
+    if(samples_left) {
+        if(control_block.vflag>=1) fprintf(stderr, "first getting the %ld samples_left starting at location %p\n", 
+                                           samples_left, rawinput.pf.sub.data + control_block.subint_offset + control_block.chanbytes - samples_left);
+	    last_num_samples_read = unpack_samples(rawinput.pf.sub.data + control_block.subint_offset + control_block.chanbytes - samples_left, 
+                                              samples_left,                          // samples left does not include overlap
+                                              control_block.polarization,
+                                              this_tapebuffer);   				    // unpack samples to the return vector   
+        tapebuffer.push_back(this_tapebuffer);                                      // this will be a partially full buffer
+        this_tapebuffer.data.clear();       
+        samples_left = 0;
+    }
+    if(control_block.vflag>=2) {
+        long reent_total_samples = 0;
+        for(int buffer_i=0; buffer_i < tapebuffer.size(); buffer_i++) {
+            reent_total_samples += tapebuffer[buffer_i].data.size();
+            fprintf(stderr, "re-entry 2 tapebuffer %d has %ld samples\n", buffer_i, tapebuffer[buffer_i].data.size());
+        }
+        fprintf(stderr, "re-entry 2 - total_samples = %ld (%ld) in %ld tapebuffers\n", reent_total_samples, total_samples, tapebuffer.size());
+    }
+    // end take care of any samples left over in the guppi buffer
+
+    // read blocks until we run out of data or the numblocks request is met
+    int round = 0;
     do{    
+        //if(control_block.vflag>=1) fprintf(stderr, "ROUND %d ========================================================\n", round);
+        log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG,"ROUND %d ========================================================\n", round); 
+        // retval = 1 : we have a new block, which may be empty if we are fast forwarding to the point of resumption
+        // retval = 0 : we do not have a new block. 
+        // rawinput.invalid = 1 : we are out of raw data or have detected corruption
+        // rawinput.invalid = 0 : good to continue with current file or open the next file in the series.
         retval = read_block(
 	                control_block,
                     rawinput,
@@ -586,52 +720,77 @@ long int read_blocks_guppi(char *           file_prefix,
                     filname,
                     start_data_time,
                     end_data_time,
-                    j,
+                    filecnt,
                     this_tapebuffer
                  );
-        if(retval) {
-            //tapebuffer.push_back(this_tapebuffer);
-            tapebuffer.push_back(this_tapebuffer);
-            this_tapebuffer.data.clear();
+            if(retval && this_tapebuffer.data.size() > 0) {         // if retval (OK) and no data, assume fast forward resumption
+                this_tapebuffer.header.data_size = last_num_samples_read;
+                tapebuffer.push_back(this_tapebuffer);
+                if(control_block.vflag>=1) print_header(this_tapebuffer);
+                round++;
+                this_tapebuffer.data.clear();       
+            }
+        if(control_block.vflag>=2) {
+            reent_total_samples = 0;
+//          for(int buffer_i=0; buffer_i < tapebuffer.size(); buffer_i++) {
+//              reent_total_samples += tapebuffer[buffer_i].data.size();
+//          }
+//          fprintf(stderr, "re-entry 3 - total_samples = %ld (%ld) in %ld tapebuffers\n", reent_total_samples, total_samples, tapebuffer.size());
+        }          
+    } while((!(rawinput.invalid))                                                       && 
+            total_samples < limit_samples);
+    fprintf(stderr, "========================================================\n");
+    // end read blocks until we run out of data or the numblocks request is met
+
+    samples_left = control_block.chanbytes - last_num_samples_read;             // set up for next call
+
+    // optionally dump a full tapebuffer
+    if(dumpraw) dump_tapebuffer(file_prefix, channel);
+         
+    if(control_block.vflag>=1) {
+             fprintf(stderr, "NUM SAMPLES total %ld final buffer contains %ld of a possible %d leaving %ld for the next time through\n", 
+             total_samples, last_num_samples_read, control_block.chanbytes, control_block.chanbytes-last_num_samples_read);
+    }
+
+    if(control_block.vflag>=2) {
+        reent_total_samples = 0;
+        for(int buffer_i=0; buffer_i < tapebuffer.size(); buffer_i++) {
+            reent_total_samples += tapebuffer[buffer_i].data.size();
+            fprintf(stderr, "re-entry 4 tapebuffer %d has %ld samples\n", buffer_i, tapebuffer[buffer_i].data.size());
         }
-    } while((!(rawinput.invalid)) && (control_block.currentblock <= (numblocks + control_block.startblock - 1)));
+        fprintf(stderr, "re-entry 4 - total_samples = %ld (%ld) in %ld tapebuffers\n", reent_total_samples, total_samples, tapebuffer.size());
+    }
 
     fprintf(stderr, "getting coordinate history...\n");
     get_coord_history();
 	
     fprintf(stderr, "finishing up...\n");
 
-    if(control_block.vflag>=1) fprintf(stderr, "bytes: %ld\n",by);
-	
-    // free the raw data read buffer
-    if (rawinput.pf.sub.data) {
-        fprintf(stderr, "freeing rawinput.pf.sub.data at %p\n", rawinput.pf.sub.data);
-	    free(rawinput.pf.sub.data);
-        rawinput.pf.sub.data = NULL;
-	    fprintf(stderr, "freed subint data buffer\n");
-    }
-
-    fprintf(stderr, "done\n");
-
-    // commented out by jeffc
-    //free(channelbuffer);
-
     int blocks_read = tapebuffer.size();
-    if(control_block.vflag>=1) fprintf(stderr, "grabbed %Ld blocks covering %lf seconds of time\n", 
-                                       blocks_read, (end_data_time-start_data_time)*86400);
-    return blocks_read;
+    if(control_block.vflag>=1) fprintf(stderr, "grabbed %ld samples from %Ld blocks covering %lf seconds of time.  Current block is %ld = %d\n", 
+                                       total_samples, blocks_read, (end_data_time-start_data_time)*86400, 
+                                       control_block.currentblock, tapebuffer[tapebuffer.size()-1].header.dataseq);
+    start_data_time = end_data_time;    // set up for next call
+
+    this_tapebuffer.data.clear();       
+    if(total_samples != limit_samples) {
+        return 0;                           // error or EOF TODO should differentiate
+    } else {
+        return total_samples;
+    }
 
 }   // end read_blocks_guppi()
 
 //-------------------------------------------------------
-int unpack_samples(unsigned char * raw, long int count, int pol, dr2_compact_block_t &this_tapebuffer) {
+unsigned long unpack_samples_2bit(unsigned char * raw, long int count, int pol, dr2_compact_block_t &this_tapebuffer) {
 //-------------------------------------------------------
-// unpack guppi 2 bit complex samples into a vector of complex signed chars
+// unpack guppi 2 bit complex samples into a vector of complex signed chars.  Here we have 1 byte per sample.
 // pol is polarization (0 for X, 1 for Y) 
 
-	 int i;
-     int shift_factor = pol * 2;    // shift_factor will be 0 or 2
+	 long i;
+     int pol_shift = pol * 2;    // pol_shift will be 0 or 2
 	 float quantlookup[4];
+     const int stride = 1;       // number of bytes in each time (real,imag,2pols)
      std::complex<signed char> sample;
 
      // the * 10 is to keep some of the precision intact as we
@@ -641,27 +800,71 @@ int unpack_samples(unsigned char * raw, long int count, int pol, dr2_compact_blo
 	 quantlookup[2] = -1.0          * 10;
 	 quantlookup[3] = -3.3358750    * 10;
 
-	 for(i=0; i < count; i++) {
-          // real (2 bits of raw data)
-		  sample.real( (signed char)quantlookup[( raw[i] >> (shift_factor * 2)      & 1)        +   // bit 0 or 4  
-                                                ((raw[i] >> (shift_factor * 2 + 1)  & 1) * 2)]      // bit 1 or 5
+     // short circuit in the case of getting the total number of samples that we want.
+     // The raw pointer will left where it is for the next time through.
+	 for(i=0; i < count && total_samples < limit_samples; i+=stride) {
+          // Note that we swap real/imag from the guppi ordering to get the order that the splitter expects.
+          // imag (2 bits of raw data)
+		  sample.imag( (signed char)quantlookup[( raw[i] >> (pol_shift * 2)      & 1)        +   // bit 0 or 4  
+                                                ((raw[i] >> (pol_shift * 2 + 1)  & 1) * 2)]      // bit 1 or 5
                      ); 
-		  // imag (2 bits of raw data)
-		  sample.imag( (signed char)quantlookup[( raw[i] >> (shift_factor+1 * 2)      & 1)      +   // bit 2 or 6 
-                                                ((raw[i] >> (shift_factor+1 * 2 + 1)  & 1) * 2)]    // bit 3 or 7
+		  // real (2 bits of raw data)
+		  sample.real( (signed char)quantlookup[( raw[i] >> ((pol_shift+1) * 2)      & 1)      +   // bit 2 or 6 
+                                                ((raw[i] >> ((pol_shift+1) * 2 + 1)  & 1) * 2)]    // bit 3 or 7
                      ); 
           // add this sample to our vector
           this_tapebuffer.data.push_back(sample);
-	 }
+          total_samples++;
+    }
 
 //fprintf(stderr, "old count : %ld    new count : %ld\n", count,  this_tapebuffer.data.size());
 //fprintf(stderr, "old data  : %d %d  new data  :  %d %d\n", samples[0], samples[1], this_tapebuffer.data[0].real(), this_tapebuffer.data[0].imag());
 //fprintf(stderr, "old data  : %d %d  new data  :  %d %d\n", samples[2], samples[3], this_tapebuffer.data[1].real(), this_tapebuffer.data[1].imag());
 //fprintf(stderr, "old data  : %d %d  new data  :  %d %d\n", samples[count*2-2], samples[count*2-1], this_tapebuffer.data[count-1].real(), this_tapebuffer.data[count-1].imag());
 
-	 return 0;
+	 return i/stride;   // == i in this case
+}
+
+
+//-------------------------------------------------------
+unsigned long unpack_samples_8bit(unsigned char * raw, long int count, int pol, dr2_compact_block_t &this_tapebuffer) {
+//-------------------------------------------------------
+// unpack 8 bit data. Here we have 4 bytes per sample
+// pol is polarization (0 for X, 1 for Y) 
+
+	 long i;
+     int pol_shift = pol * 2;    // pol_shift will be 0 or 2
+     const int stride = 4;       // number of bytes in each time (real,imag,2pols)
+     std::complex<signed char> sample;
+
+	 for(i=0; i < count && total_samples < limit_samples; i+=stride) {
+          // Note that we swap real/imag from the guppi ordering to get the order that the splitter expects.
+          sample.imag(raw[i+pol_shift]);
+          sample.real(raw[i+1+pol_shift]);
+          // add this sample to our vector
+          this_tapebuffer.data.push_back(sample);
+          total_samples++;
+	 }
+
+	 return i/stride;
+}
+
+
+//-------------------------------------------------------
+unsigned long unpack_samples(unsigned char * raw, long int count, int pol, dr2_compact_block_t &this_tapebuffer) {
+//-------------------------------------------------------
+
+    if(raw_bit_depth == 2) {
+        return(unpack_samples_2bit(raw, count, pol, this_tapebuffer));   	
+    } else if(raw_bit_depth == 8) {
+        return(unpack_samples_8bit(raw, count, pol, this_tapebuffer));   	
+    } else {
+	    fprintf(stderr,"ERR: unsupported bit depth, exiting...\n");
+	    exit(1);
+    }
 }
 
+
 //-------------------------------------------------------
 int exists(const char *fname) {
 //-------------------------------------------------------
diff --git a/splitter_pfb/mb_splitter.cpp b/splitter_pfb/mb_splitter.cpp
index b130f68..17335a4 100644
--- a/splitter_pfb/mb_splitter.cpp
+++ b/splitter_pfb/mb_splitter.cpp
@@ -54,6 +54,7 @@ R_RSA_PRIVATE_KEY key;
 // configuration tables
 receiver_config rcvr;
 settings splitter_settings;
+int root_analysis_cfg_id;
 
 // TEMPLATE DEFS ------------------------------------------------------
 // IMPORTANT: a change to a template should *always* include a change
@@ -105,8 +106,14 @@ int polyphase;
 int iters=-1;
 int beam;
 int pol;
-int alfa;
-int gbt;
+int alfa = 0; 
+int gbt = 0;
+int channel;
+int raw_bit_depth = 0; // bit depth of raw data (required for guppi data).  A depth of N means N real, N imag
+int samples_per_byte;  // real samples/byte
+int dumpsubband = -1;  // default to not dumping
+int dumpraw = 0;       // default to not dumping
+enum file_types {dr2, guppi};
 int useanalysiscfgid = 0;
 int usereceivercfgid = 0;
 int userecordercfgid = 0;
@@ -155,8 +162,9 @@ void cleanup(void) {
 int process_command_line(int argc, char *argv[],char **tape_device,
                          int *norewind, int *startblock, int *resumetape,
                          int *nodb, int *dataclass, int *atnight,
-                         int *max_wus_ondisk, char **projectdir,
-			 int *iters, int *beam, int *pol, int *alfa, int *gbt,
+                         int *max_wus_ondisk, char **projectdir, int *iters, 
+                         int *beam, int *pol, int *alfa, int *gbt, int *channel, 
+                         int *raw_bit_depth, int *dumpsubband, int *dumpraw,
                          int *useanalysiscfgid, int *usereceivercfgid,
                          int *userecordercfgid, int *usesplittercfgid) {
 //-------------------------------------------------------------------------
@@ -176,6 +184,9 @@ int process_command_line(int argc, char *argv[],char **tape_device,
             } else
               if (!strncmp(argv[i],"-atnight",MAX(strlen(argv[i]),7))) {
                 *atnight=1;
+              } else 
+                if (!strncmp(argv[i],"-dumpraw",MAX(strlen(argv[i]),7))) {
+                    *dumpraw = 1;
               } else
                 if (!strncmp(argv[i],"-nodb",MAX(strlen(argv[i]),4))) {
                   if (*resumetape) {
@@ -220,10 +231,9 @@ int process_command_line(int argc, char *argv[],char **tape_device,
 		                        }
 			                    *alfa=1;
                           } else if (!strncmp(argv[i],"-gbt",MAX(ep-argv[i],3))) {
-			                    sscanf(ep+1,"%d,%d",beam,pol);
-			                    if ((*beam != 0)  ||
-			                        ((*pol<0) || (*pol>1))) {
-                                    log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"GBT receivers must be specified with beam 0 and polarization (0-1), i.e. -gbt=0,1\n");
+			                    sscanf(ep+1,"%d,%d",channel,pol);
+			                    if (*pol<0 || *pol>1) {
+                                    log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"GBT receivers must be specified with a channel and polarization (0-1), i.e. -gbt=0,1\n");
 				                    exit(EXIT_FAILURE);
 		                        }
 			                    *gbt=1;
@@ -234,6 +244,11 @@ int process_command_line(int argc, char *argv[],char **tape_device,
                               return(1);
                             }
                             sscanf(ep+1,"%d",startblock);
+                          } else if (!strncmp(argv[i],"-dumpsubband",MAX(ep-argv[i],2))) {
+                              sscanf(ep+1,"%d",dumpsubband);
+                          } else if (!strncmp(argv[i],"-rawbitdepth",MAX(ep-argv[i],2))) {
+                              sscanf(ep+1,"%d",raw_bit_depth);
+                              samples_per_byte = 8/(*raw_bit_depth);
                           } else if (!strncmp(argv[i],"-max_wus_ondisk",MAX(ep-argv[i],2))) {
                               sscanf(ep+1,"%d",max_wus_ondisk);
                           } else if (!strncmp(argv[i],"-dataclass",MAX(ep-argv[i],2))) {
@@ -267,16 +282,20 @@ int process_command_line(int argc, char *argv[],char **tape_device,
   //if (! *scidb) return (1);
   if (! *projectdir) return (1);
   if (! *tape_device) return (1);
+  if (*gbt && !*raw_bit_depth) {
+    log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"GBT data requires a bit depth : -rawbitdepth=n\n", gbt);
+    exit(EXIT_FAILURE);
+  }
+
 
   return 0;
 }
 
 //-------------------------------------------------------------------------
-int get_config(telescope_id &tel) {
+int open_dbs() {
 //-------------------------------------------------------------------------
+
   FILE *tmpfile;
-  char keyfile[1024];
-  char buf[1024];
 
   // Will initially open the science DB 
   if (!db_change(sah_config.scidb_name)) {
@@ -326,43 +345,89 @@ int get_config(telescope_id &tel) {
 
   boinc_db.close();
 
-  tel= channel_to_receiverid[beam_pol_to_channel[bmpol_t(beam,pol)]];
+}
+
+//-------------------------------------------------------------------------
+int get_config(telescope_id &tel, int file_type, dataheader_t dataheader, int pol) {
+//-------------------------------------------------------------------------
+  //FILE *tmpfile;
+  char keyfile[1024];
+  char buf[1024];
+  float channel_freq = 0;
+
+  // tel equates to s4_id and this is where we resolve it.  Also...
+  // A guppi raw file can be from any one of a number of different receivers.
+  // A guppi raw file is generally of such wide bandwidth that we need to configure
+  // with the individual channel frequency.  A given invocation of the splitter
+  // specifies a single channel.
+  if(file_type == guppi) {          // GBT
+    std::string frontend_s = dataheader.frontend;
+    tel = frontend_pol_to_receiverid[frontend_pol_t(frontend_s, pol)]; 
+    channel_freq = dataheader.sky_freq;
+  } else if(file_type == dr2) {     // ALFA
+    tel = channel_to_receiverid[beam_pol_to_channel[bmpol_t(beam,pol)]];
+  } else {
+    log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"Invalid file type %d\n", file_type);
+    exit(1);
+  }
 
-  sprintf(buf,"where active=%d and receiver_cfg=(select id from receiver_config where s4_id=%d)",app.id,AO_ALFA_0_0);
-  if (usereceivercfgid > 0) { 
+  log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,"Using receiver config with s4_id = %d\n", tel);
+
+  // obtain the settings row - we query on app.od and receiver_config 
+  // because there are multiple settings per app.id
+  if (usereceivercfgid > 0) {                           // user requested a specific receiver_config   
     sprintf(buf,"where active=%d and receiver_cfg=%d",app.id,usereceivercfgid);
+    if (!splitter_settings.fetch(std::string(buf))) {     // fetch
+        log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"Unable to find active settings for app.id = %d\n",app.id);
+        exit(1);
+    }
+  } else {                                              // no user request - use tel to find receiver_config 
+    sprintf(buf,"where active=%d and receiver_cfg=(select id from receiver_config where s4_id=%d)",app.id,tel);
+    if (!splitter_settings.fetch(std::string(buf))) {     // fetch
+        log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"Unable to find active settings for app.id = %d s4_id = %d\n",app.id, tel);
+        exit(1);
     }
-  if (!splitter_settings.fetch(std::string(buf))) {
-    log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"Unable to find active settings for app.id=%d\n",app.id);
-    exit(1);
   }
 
-  sprintf(buf,"where s4_id=%d and id>=%d",tel,splitter_settings.receiver_cfg.id);
-  if (usereceivercfgid > 0) { sprintf(buf,"where id=%d",usereceivercfgid); }
-  rcvr.fetch(buf);
-  if (usereceivercfgid > 0) { 
+  // obtain the receiver config row
+  if (usereceivercfgid > 0) {                           // user requested a specific receiver config                                                        
     log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,"Using receiver cfg id: %d (set by user)\n",usereceivercfgid);
-    splitter_settings.receiver_cfg = usereceivercfgid; 
-    splitter_settings.receiver_cfg->fetch();
-  } else { 
-    splitter_settings.receiver_cfg->fetch(buf);
+    sprintf(buf,"where id=%d",usereceivercfgid); 
+  } else {                                              // no user request - receiver config comes from settings
+    sprintf(buf,"where s4_id=%d",tel);     
+  }  
+  rcvr.fetch(buf);                                      // fetch 
+  if(channel_freq) {
+    // scale FWHM beamwidth by channel_freq (which is in Hz)
+    // then replace receiver center (which is in MHz) with channel freq
+    rcvr.beam_width  = rcvr.beam_width * rcvr.center_freq*1e6/channel_freq;   
+    rcvr.center_freq = channel_freq/1e6;                                      
   }
+  splitter_settings.receiver_cfg = rcvr;            // copy for WU header inclusion
+
+  // obtain the recorder config row
   if (userecordercfgid > 0) { 
     log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,"Using recorder cfg id: %d (set by user)\n",userecordercfgid);
     splitter_settings.recorder_cfg = userecordercfgid; 
   }
-  splitter_settings.recorder_cfg->fetch(); 
+  splitter_settings.recorder_cfg->fetch();              // fetch
+
+  // obtain the splitter config row
   if (usesplittercfgid > 0) { 
     log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,"Using splitter cfg id: %d (set by user)\n",usesplittercfgid);
     splitter_settings.splitter_cfg = usesplittercfgid; 
   }
-  splitter_settings.splitter_cfg->fetch();
+  splitter_settings.splitter_cfg->fetch();              // fetch
+
+  // obtain the root analysis config row
   if (useanalysiscfgid > 0) { 
     log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,"Using analysis cfg id: %d (set by user)\n",useanalysiscfgid);
     splitter_settings.analysis_cfg = useanalysiscfgid;
   } 
-  splitter_settings.analysis_cfg->fetch();
+  splitter_settings.analysis_cfg->fetch();              // fetch
+  root_analysis_cfg_id=splitter_settings.analysis_cfg.id;
 
+  // finally, print all settings
   log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL, "settings: \n\n%s\n", splitter_settings.print_xml(1,1,0).c_str());
  
   strcpy(keyfile, projectdir);
@@ -415,7 +480,6 @@ int check_free_disk_space() {
   if (vfsbuf.f_frsize==0) vfsbuf.f_frsize=512;
   if (vfsbuf.f_bavail < (100000*1024/vfsbuf.f_frsize)) {
     log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,"Not enough free disk space in working directory to continue\n");
-    log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,"Not enough free disk space in working directory to continue\n");
     exit(EXIT_FAILURE);
   }
   
@@ -512,25 +576,25 @@ int main(int argc, char *argv[]) {
   char keyfile[1024];
   char tmpstr[1024];
   char buf[1024];
-  telescope_id tel;
+  telescope_id tel = (telescope_id)-1;    // -1 = no telescope ID (aka s4_id) yet
 
   int good_read;
   long num_blocks_read;
   int vflag;
-  enum file_type_t {dr2, guppi};
   int file_type = 0;        // default to dr2 for now
-
+  int beamchan;
 
   /* Process command line arguments */
   if (process_command_line(argc,argv,&tape_device,&norewind,&startblock,&resumetape,
                            &nodb,&dataclass,&atnight,&max_wus_ondisk,&projectdir,&iters,
-			   &beam,&pol,&alfa,&gbt,&useanalysiscfgid,&usereceivercfgid,
-                           &userecordercfgid,&usesplittercfgid))  {
+			               &beam,&pol,&alfa,&gbt,&channel,&raw_bit_depth,&dumpsubband,
+                           &dumpraw, &useanalysiscfgid, &usereceivercfgid, &userecordercfgid,
+                           &usesplittercfgid))  {
     fprintf(stderr,"Usage: splitter tape_device -projectdir=s [-atnight] [-nodb]\n"
     "[-xml] [-gregorian] [-resumetape | -norewind | -startblock=n] [-dataclass=n]\n"
     "[-max_wus_on_disk=n] [-iterations=n] [-trigger_file_path=filename]\n"
-    "[-alfa=beam,pol] [-analysis_config=id] [-receiver_config=id]\n"
-    "[-recorder_config=id] [-splitter_config=id]\n");
+    "[-alfa=beam,pol] [-gbt=beam,pol -rawbitdepth=n] [-analysis_config=id] [-receiver_config=id]\n"
+    "[-recorder_config=id] [-splitter_config=id] [-dumpsubband=subband] [-dumpraw]\n");
     exit(EXIT_FAILURE);
   }
 
@@ -559,7 +623,8 @@ int main(int argc, char *argv[]) {
     log_messages.printf(SCHED_MSG_LOG::MSG_NORMAL,"max_total_results   = %d\n", sah_config.max_total_results);
   }
 
-  get_config(tel);
+  //get_config(tel, file_type);
+  open_dbs();
 
   check_for_halt();
 
@@ -568,10 +633,10 @@ int main(int argc, char *argv[]) {
         log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"Unable to open tape device\n");
         exit(EXIT_FAILURE);
     }
-    find_start_point_dr2(tape_fd, beam, pol);
+    beamchan = 2*beam+pol;
+    find_start_point_dr2(tape_fd, beam, pol, beamchan);
   } else if(file_type == guppi) {
-    //log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"guppi file type not implemented\n");
-    //exit(1);
+    beamchan = 2*channel+pol;
   } else {
     log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"invalid file type");
     exit(1);
@@ -595,7 +660,7 @@ int main(int argc, char *argv[]) {
   //      what is needed for WU overlap.
   while (iters--) {
 
-    // check, and maaybe wait on, various run conditions
+    // check, and maybe wait on, various run conditions
     fflush(stderr);                         // TODO why are we fflushing stderr?
     if (atnight) wait_until_night();
     check_for_halt();
@@ -614,25 +679,27 @@ int main(int argc, char *argv[]) {
                                     pol,
                                     vflag);
     } else if(file_type == guppi) {
-        // UNcomment the following two lines for a production build
-        log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"guppi file type not implemented\n");
-        exit(1);
-
         // guppi data for a WUG may be spread out over more than one file.  File naming
         // determines the order of files.  Thus, we pass a partial file name instead of
         // an open descriptor.
-        std::vector<dr2_compact_block_t> tapebuffer_guppi;
-	    long int numblocks          = 325;  // gives ~107s of data for guppi kepler, TODO - needs overlap, specify in secs, not blocks? 
-	    int channel                 = 1;
-
+	    const long int numsamples  = 256*1048576;              // 256*2**20, ie data for 256 WUs, 2**20 samples each 
         vflag=1;
 	    good_read = read_blocks_guppi(tape_device,             // file_prefix, raw guppi input         
                                       startblock,  
-                                      numblocks,               // what about WU time overlap? 
+                                      numsamples,        
                                       channel,                 // data selection for guppi is channel wise
                                       pol, 
                                       vflag);
         fprintf(stderr, "goodread = %ld\n", good_read);
+#if 0
+        long total_samples;
+        total_samples = 0;
+                for(int buffer_i=0; buffer_i < tapebuffer.size(); buffer_i++) {
+                    total_samples += tapebuffer[buffer_i].data.size();
+                }
+        fprintf(stderr, "back in splitter - total_samples = %ld\n", total_samples);
+#endif
+
     } else {
         log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"invalid file type");
         exit(1);
@@ -641,9 +708,10 @@ int main(int argc, char *argv[]) {
     if(!good_read) {
       break;        // drop out of main loop on first bad read
     } else {
-      // COMMENT the following line for a production build
-      //continue;   // short circuit for guppi/gbt testing
-      if (make_wu_headers(tapebuffer,tel,wuheaders)) {
+      if(tel == (telescope_id)-1) {                                 // -1 indicates get_config() not yet called            
+        get_config(tel, file_type, tapebuffer[0].header, pol);      // do once, assume constant for this input file
+      }
+      if (make_wu_headers(tapebuffer,tel,beamchan,wuheaders)) {
         int child_pid=-1;
         log_messages.printf(SCHED_MSG_LOG::MSG_DEBUG,"doing transform..." );
         do_transform(tapebuffer);
diff --git a/splitter_pfb/mb_splitter.h b/splitter_pfb/mb_splitter.h
index 6b52bc3..3b627f3 100644
--- a/splitter_pfb/mb_splitter.h
+++ b/splitter_pfb/mb_splitter.h
@@ -34,6 +34,8 @@ extern char appname[256];
 extern int nodb;
 extern int resumetape;
 extern int startblock;
+extern int raw_bit_depth;
+extern int samples_per_byte;
 extern int norewind;
 extern int output_xml;
 extern int polyphase;
@@ -43,7 +45,9 @@ extern char * projectdir;
 extern char trigger_file_name[1024];
 extern receiver_config rcvr;
 extern settings splitter_settings;
-
+extern int root_analysis_cfg_id;
+extern int dumpsubband;
+extern int dumpraw;
 
 /* Buffer that holds tape data */
 extern std::vector<dr2_compact_block_t> tapebuffer;
diff --git a/splitter_pfb/mb_wufiles.cpp b/splitter_pfb/mb_wufiles.cpp
index 005d469..816aa05 100644
--- a/splitter_pfb/mb_wufiles.cpp
+++ b/splitter_pfb/mb_wufiles.cpp
@@ -51,8 +51,10 @@ std::vector<std::vector<unsigned char> > bin_data;
 
 extern APP_CONFIG sah_config;
 
-int make_wu_headers(std::vector<dr2_compact_block_t> &tapebuffer, telescope_id
-tel, std::vector<workunit> &wuheader) {
+int make_wu_headers(std::vector<dr2_compact_block_t> &tapebuffer, 
+                    telescope_id tel, 
+                    int beamchan,
+                    std::vector<workunit> &wuheader) {
   int procid=getpid();
   double receiver_freq;
   int bandno;
@@ -82,8 +84,18 @@ tel, std::vector<workunit> &wuheader) {
     tapebuffer[0].header.name,
     procid, 
     tapebuffer[0].header.dataseq,
-    (tel-AO_430)&0xff,
+    (tel-AO_430)&0xff,                 
     s.id);
+
+  // refetch root analysis_config - we need a pristine copy 
+  // because per WUG changes are made below 
+  splitter_settings.analysis_cfg.id=root_analysis_cfg_id;
+  splitter_settings.analysis_cfg->fetch();
+  if(splitter_settings.analysis_cfg.id == 0) {
+     log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"refetch of analysis_config failed\n");
+     exit(1);
+  }
+
   wugrp.receiver_cfg=r; 
   wugrp.recorder_cfg=s.recorder_cfg; 
   wugrp.splitter_cfg=s.splitter_cfg; 
@@ -212,12 +224,13 @@ tel, std::vector<workunit> &wuheader) {
   wugrp.alfa_filter_bank = tapebuffer[0].header.scram_if1.alfaFb ? 1 : 0; 
 
   wugrp.tape_info->id=0;
-  sprintf(buf,"%d",tel-AO_ALFA_0_0);
+  sprintf(buf,"%d",beamchan);              
   wugrp.tape_info->fetch(std::string("where name=\'")+tapebuffer[0].header.name+"\' and beam="+buf);
   wugrp.tape_info->start_time=tapebuffer[0].header.data_time.jd().uval();
   wugrp.tape_info->last_block_time=wugrp.tape_info->start_time;
   wugrp.tape_info->last_block_done=tapebuffer[0].header.dataseq;
-  wugrp.tape_info->beam=(tel-AO_ALFA_0_0)&0xff;
+fprintf(stderr, "last_block_done = %d\n", wugrp.tape_info->last_block_done);
+  wugrp.tape_info->beam=beamchan;            
 
   if (!nodb) {
     if (wugrp.tape_info.id) {
@@ -230,6 +243,8 @@ tel, std::vector<workunit> &wuheader) {
       strlcpy(wugrp.tape_info->name,tapebuffer[0].header.name,sizeof(wugrp.tape_info->name));
       wugrp.tape_info->insert();
     }
+  } else {  // nodb
+      strlcpy(wugrp.tape_info->name,tapebuffer[0].header.name,sizeof(wugrp.tape_info->name));
   }
 
   if (!nodb) {
@@ -278,13 +293,14 @@ tel, std::vector<workunit> &wuheader) {
     sprintf(tmpstr,"./wu_inbox/%s",wuheader[i].name);
     if ((tmpfile=fopen(tmpstr,"w"))) {
       fprintf(tmpfile,"<workunit>\n");
+      fprintf(tmpfile,"<app_name>%s</app_name>\n",appname);
       fprintf(tmpfile,wuheader[i].print_xml().c_str());
       fclose(tmpfile);
     } else {
       log_messages.printf(SCHED_MSG_LOG::MSG_CRITICAL,"Unable to open file ./wu_inbox/%s, errno=%d\n",wuheader[i].name,errno);
       exit(1);
     }
-    bin_data[i].reserve(wuheaders[i].group_info->recorder_cfg->bits_per_sample*
+    bin_data[i].reserve(wuheaders[i].group_info->splitter_cfg->wu_bits_per_sample*
        wuheaders[i].group_info->data_desc.nsamples/8);
   }
   return(1);
@@ -349,6 +365,14 @@ void rename_wu_files() {
 
     struct stat sbuf;
     if (!stat(oldname,&sbuf) && (tmpfile=fopen(oldname,"a"))) {
+        if(dumpsubband != -1 && i == dumpsubband) {     // dump real and imaginary of each sample for requested subband (if any)
+            fprintf(stderr, "bin_data[%d] is %ld bytes or %ld samples long\n", i, bin_data[i].size(), bin_data[i].size()/2);
+            for(int sample_i=0; sample_i < bin_data[i].size()-1; sample_i += 2) {
+                fprintf(stderr, "%x = %d   %x = %d\n", 
+                        bin_data[i][sample_i],   bin_data[i][sample_i],
+                        bin_data[i][sample_i+1], bin_data[i][sample_i+1]);
+            }
+        }  // end subband dump
        std::string tmpstr=xml_encode_string(bin_data[i],encoding);
        fprintf(tmpfile,"<data length=%ld encoding=\"%s\">",tmpstr.size(),
             xml_encoding_names[encoding]);
diff --git a/splitter_pfb/mb_wufiles.h b/splitter_pfb/mb_wufiles.h
index 5fb95e2..fc11001 100644
--- a/splitter_pfb/mb_wufiles.h
+++ b/splitter_pfb/mb_wufiles.h
@@ -9,8 +9,10 @@
 
 extern  std::vector<std::vector<unsigned char> > bin_data;
 
-int make_wu_headers(std::vector<dr2_compact_block_t> &tapebuffer, telescope_id tel, 
-    std::vector<workunit> &wuheader) ;
+int make_wu_headers(std::vector<dr2_compact_block_t> &tapebuffer, 
+                    telescope_id tel, 
+                    int beamchan,
+                    std::vector<workunit> &wuheader) ;
 void write_wufile_blocks(int nbytes) ;
 void rename_wu_files();
 
diff --git a/validate/sah_result.cpp b/validate/sah_result.cpp
index a61597a..522e56e 100644
--- a/validate/sah_result.cpp
+++ b/validate/sah_result.cpp
@@ -91,7 +91,6 @@ int SAH_RESULT::parse_file(FILE* f) {
 
     memset(&s, 0, sizeof(s));
     while (fgets(buf, 256, f)) {
-
         if (match_tag(buf, "<spike>")) {
             memset(&s, 0, sizeof(s));
             s.type = SIGNAL_TYPE_SPIKE;
@@ -140,6 +139,8 @@ int SAH_RESULT::parse_file(FILE* f) {
             memset(&s, 0, sizeof(s));
             s.type = SIGNAL_TYPE_BEST_TRIPLET;
 
+        } else if (parse_double(buf, "<setiathome_version>",d)) {
+            setiathome_version = d;
         } else if (parse_double(buf, "<ra>", d)) {
             s.ra = d;
         } else if (parse_double(buf, "<decl>", d)) {
diff --git a/validate/sah_result.h b/validate/sah_result.h
index 7203b02..30534be 100644
--- a/validate/sah_result.h
+++ b/validate/sah_result.h
@@ -65,6 +65,7 @@ struct SAH_RESULT {
     int num_signals;
     bool found_best_autocorr;
     bool is_overflow;
+    double setiathome_version;
 };
 
 extern int write_sah_db_entries(SAH_RESULT&);
diff --git a/validate/sah_validate.cpp b/validate/sah_validate.cpp
index 6e4f74f..b1167f3 100644
--- a/validate/sah_validate.cpp
+++ b/validate/sah_validate.cpp
@@ -206,6 +206,7 @@ int validate_plural(vector<RESULT>& results, vector<SAH_RESULT>& sah_results, lo
     for (i=0; i<sah_results.size()-1; i++) {    // scan with [i] to find canonical
         if (!sah_results[i].have_result) continue;
         check_overflow_result(results[i]);
+
         // Someone is trying to process v7 workunits with v6
         if (!sah_results[i].found_best_autocorr && 
                 !(sah_results[i].is_overflow || results[i].runtime_outlier)  && 
@@ -217,6 +218,18 @@ int validate_plural(vector<RESULT>& results, vector<SAH_RESULT>& sah_results, lo
             );
             continue;
         }   
+        // Someone is trying to process v8 workunits with v7
+        if (((sah_results[i].setiathome_version<7.90) || (sah_results[i].setiathome_version>8.89))&& 
+                !(sah_results[i].is_overflow || results[i].runtime_outlier)  && 
+                !strcmp(app_name,"setiathome_v8")) {
+            results[i].validate_state = VALIDATE_STATE_INVALID;
+            log_messages.printf(
+                SCHED_MSG_LOG::MSG_DEBUG,
+                "[RESULT#%ld] is from an invalid app_version (%f)\n", results[i].id, sah_results[i].setiathome_version
+            );
+            continue;
+        }   
+
         for (j=i+1; j<sah_results.size(); j++) {     // scan with [j] to match [i]
             if (!sah_results[j].have_result) continue;
             check_overflow_result(results[j]);
@@ -231,6 +244,16 @@ int validate_plural(vector<RESULT>& results, vector<SAH_RESULT>& sah_results, lo
                 );
                 continue;
             } 
+            if (((sah_results[j].setiathome_version<7.90) || (sah_results[j].setiathome_version>8.89))&& 
+                    !(sah_results[j].is_overflow || results[j].runtime_outlier)  && 
+                    !strcmp(app_name,"setiathome_v8")) {
+                results[j].validate_state = VALIDATE_STATE_INVALID;
+                log_messages.printf(
+                    SCHED_MSG_LOG::MSG_DEBUG,
+                    "[RESULT#%ld] is from an invalid app_version (%f)\n", results[j].id,sah_results[j].setiathome_version
+                );
+                continue;
+            } 
             if (sah_results[i].strongly_similar(sah_results[j])) {
                 log_messages.printf(
                     SCHED_MSG_LOG::MSG_DEBUG,
@@ -262,6 +285,29 @@ int validate_plural(vector<RESULT>& results, vector<SAH_RESULT>& sah_results, lo
         nvalid = 0;
         for (k=0; k<sah_results.size(); k++) {   // scan with [k] to validate rest of set against canonical
             if (!sah_results[k].have_result) continue;
+            check_overflow_result(results[k]);
+            // Someone is trying to process v7 workunits with v6
+            if (!sah_results[k].found_best_autocorr && 
+                    !(sah_results[k].is_overflow || results[k].runtime_outlier)  && 
+                    !strcmp(app_name,"setiathome_v7")) {
+                results[k].validate_state = VALIDATE_STATE_INVALID;
+                log_messages.printf(
+                    SCHED_MSG_LOG::MSG_DEBUG,
+                    "[RESULT#%ld] is from an invalid app_version\n", results[k].id
+                );
+                continue;
+            }   
+            // Someone is trying to process v8 workunits with v7
+            if (((sah_results[k].setiathome_version<7.90) || (sah_results[k].setiathome_version>8.89))&& 
+                    !(sah_results[k].is_overflow || results[k].runtime_outlier)  && 
+                    !strcmp(app_name,"setiathome_v8")) {
+                results[k].validate_state = VALIDATE_STATE_INVALID;
+                log_messages.printf(
+                    SCHED_MSG_LOG::MSG_DEBUG,
+                    "[RESULT#%ld] is from an invalid app_version (%f)\n", results[k].id,sah_results[k].setiathome_version
+                );
+                continue;
+            }   
             if (k == i || k == j) {
                 results[k].validate_state = VALIDATE_STATE_VALID;
             } else {
@@ -364,18 +410,7 @@ int check_pair(RESULT& new_result, RESULT& canonical, bool& retry) {
             "[RESULT#%ld] read/parse of %s FAILED with retval %d\n",
             new_result.id, new_result.name, retval
         );
-        // Someone is trying to process v7 workunits with v6
-        if (!sah_new.found_best_autocorr && 
-                !(sah_new.is_overflow || canonical.runtime_outlier) &&
-                !strcmp(app_name,"setiathome_v7")) {
-            new_result.validate_state = VALIDATE_STATE_INVALID;
-            retval = 0;
-            log_messages.printf(
-                SCHED_MSG_LOG::MSG_DEBUG,
-                "[RESULT#%ld] is from an invalid app_version\n", new_result.id
-            );
-            goto return_retval;
-        }   
+
         // A directory problem may be transient.
         if (retval == ERR_OPENDIR) {
             retry = true;
@@ -390,6 +425,34 @@ int check_pair(RESULT& new_result, RESULT& canonical, bool& retry) {
         }
     }
 
+    check_overflow_result(new_result);
+
+    // Someone is trying to process v7 workunits with v6
+    if (!sah_new.found_best_autocorr && 
+            !(sah_new.is_overflow || canonical.runtime_outlier) &&
+            !strcmp(app_name,"setiathome_v7")) {
+        new_result.validate_state = VALIDATE_STATE_INVALID;
+        retval = 0;
+        log_messages.printf(
+            SCHED_MSG_LOG::MSG_DEBUG,
+            "[RESULT#%ld] is from an invalid app_version\n", new_result.id
+        );
+        goto return_retval;
+    }
+    // Someone is trying to process v8 workunits with v7
+    if (((sah_new.setiathome_version<7.90) || (sah_new.setiathome_version>8.89))&& 
+            !(sah_new.is_overflow || new_result.runtime_outlier)  && 
+            !strcmp(app_name,"setiathome_v8")) {
+        new_result.validate_state = VALIDATE_STATE_INVALID;
+        retval = 0;
+        log_messages.printf(
+            SCHED_MSG_LOG::MSG_DEBUG,
+            "[RESULT#%ld] is from an invalid app_version (%f)\n", new_result.id,sah_new.setiathome_version
+        );
+        goto return_retval;
+    }   
+
+
     log_messages.printf(
         SCHED_MSG_LOG::MSG_DEBUG,
         "[RESULT#%ld] getting canonical result file %s\n",
diff --git a/xcompile/xcompile.MinGW32_on_cygwin.sh b/xcompile/xcompile.MinGW32_on_cygwin.sh
new file mode 100755
index 0000000..ae12675
--- /dev/null
+++ b/xcompile/xcompile.MinGW32_on_cygwin.sh
@@ -0,0 +1,162 @@
+#! /bin/sh 
+case $1 in 
+     --help) echo Usage: 
+              echo "$0 \<target_host_triplet\>  (default i686-\*-mingw32)"
+	      echo "  Expects to find build root in /usr/\<target_host_triplet\>/sys-root/mingw"
+	      ;;
+      i686*mingw32|x86_64*mingw32) 
+              export TARGET_HOST=$1
+              ;;
+esac
+for target_host in ${TARGET_HOST} i686-w64-mingw32 i686-pc-mingw32 x86_64-w64-mingw32 x86_64-pc-mingw32 none ; do
+   if test ${target_host} = none ; then
+     echo Cross compiling environment not found in /usr
+     exit 1
+   fi
+   echo -n Checking for cross compiling environment in /usr/${target_host}
+   if test -d /usr/${target_host}; then
+     export TARGET_HOST=${target_host}
+     echo ... found
+     break
+   fi
+   echo ... not found
+done
+
+case $TARGET_HOST in 
+	i686*)   openssl_cross=mingw 
+	         ;;
+	x86_64*) openssl_cross=mingw64
+	         ;;
+esac
+
+build_client=yes
+build_server=no
+
+export XCOMPILE_ROOT="/usr/${TARGET_HOST}/sys-root/mingw"
+guess=`../config.guess`
+export BUILD_HOST=`../config.sub ${guess}`
+export PATH="/usr/${TARGET_HOST}/bin:${XCOMPILE_ROOT}/bin:${PATH}"
+
+export CC=`which ${TARGET_HOST}-gcc`
+export CXX=`which ${TARGET_HOST}-g++`
+export AR=`which ${TARGET_HOST}-ar`
+export LD=`which ${TARGET_HOST}-ld`
+export RANLIB=`which ${TARGET_HOST}-ranlib`
+export WINDRES=`which ${TARGET_HOST}-windres`
+export CPPFLAGS="-D_WIN32_WINDOWS=0x0410 -DMINGW_WIN32 -I${XCOMPILE_ROOT}/include"
+export CFLAGS="${CPPFLAGS}"
+export CXXFLAGS="-gstabs -g3 -fpermissive"
+export LDFLAGS="-L/usr/${TARGET_HOST}/lib -L${XCOMPILE_ROOT}/lib"
+export CURL_CONFIG="${XCOMPILE_ROOT}/bin/curl-config"
+export WX_CONFIG_PATH="${XCOMPILE_ROOT}/bin/wx-config"
+pkgsearchpath="dummy"
+for dir in `find /usr/${TARGET_HOST} -name pkgconfig` ; do
+  pkgsearchpath="${pkgsearchpath}:${dir}"
+done
+for dir in `find /usr/lib -name pkgconfig` ; do 
+  pkgsearchpath="${pkgsearchpath}:${dir}"
+done
+for dir in `find /usr/share -name pkgconfig` ; do 
+  pkgsearchpath="${pkgsearchpath}:${dir}"
+done
+export PKG_CONFIG_PATH=`echo ${pkgsearchpath} | sed 's/dummy://'`
+
+if ! ( test -e ../configure && find .. -name configure -mtime -1 ) ; then
+  cd ..
+  ./_autosetup
+  cd xcompile
+fi
+
+if test $build_client != no ; then
+  if ! test -f ${XCOMPILE_ROOT}/lib/libjpeg.a ; then
+    jpegver=9a
+    wget http://ijg.org/files/jpegsrc.v${jpegver}.tar.gz
+    tar zxf jpegsrc.v${jpegver}.tar.gz
+    /bin/rm jpegsrc.v${jpegver}.tar.gz
+    cd jpeg-${jpegver}
+    ./configure --prefix=${XCOMPILE_ROOT}/ --disable-shared --host=$TARGET_HOST --build=$BUILD_HOST
+    make -j 4 all
+    make install
+    cd ..
+    rm -rf jpeg-${jpegver}
+  fi
+
+fi
+
+if test $build_client != no ; then
+  if ! test -f ${XCOMPILE_ROOT}/lib/libssl.a ; then
+    opensslver=1.0.1g
+    wget http://www.openssl.org/source/openssl-${opensslver}.tar.gz
+    tar zxf openssl-${opensslver}.tar.gz
+    /bin/rm openssl-${opensslver}.tar.gz
+    cd openssl-${opensslver}
+    ./Configure --prefix=${XCOMPILE_ROOT}/ ${CFLAGS} ${LDFLAGS} no-shared zlib $openssl_cross
+    make -j 4 all
+    make install
+    cd ..
+    rm -rf openssl-${opensslver}
+  fi
+fi
+
+if test $build_client != no ; then
+  if ! test -f ${XCOMPILE_ROOT}/lib/libcurl.a ; then
+    curlver=7.36.0
+    wget http://curl.haxx.se/download/curl-${curlver}.tar.bz2
+    tar jxf curl-${curlver}.tar.bz2
+    /bin/rm curl-${curlver}.tar.bz2
+    cd curl-${curlver}
+    ./configure --prefix=${XCOMPILE_ROOT} --enable-static --disable-shared --host=$TARGET_HOST --build=$BUILD_HOST --with-zlib=${XCOMPILE_ROOT}
+    make -j 4 all
+    make install
+    cd ..
+    rm -rf curl-${curlver}
+  fi
+fi
+
+if test $build_client != no ; then
+  if ! test -f ${XCOMPILE_ROOT}/include/GL/glut.h ; then
+    svn co http://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut freeglut
+    cd freeglut
+    mkdir build
+    cd build
+    /usr/bin/cmake -D GNU_HOST=${TARGET_HOST} \
+      -D CMAKE_TOOLCHAIN_FILE=mingw_cross_toolchain.cmake \
+      -D CMAKE_INSTALL_PREFIX=${XCOMPILE_ROOT}\
+      -D FREEGLUT_BUILD_STATIC_LIBS=ON \
+      -D FREEGLUT_BUILD_SHARED_LIBS=OFF \
+      -D FREEGLUT_BUILD_DEMOS=OFF  \
+      ..
+    make -j 4 all
+    make install
+    cd ../..
+    /bin/rm -rf freeglut
+  fi
+fi
+
+if test $build_client != no ; then
+  if ! test -f ${XCOMPILE_ROOT}/lib/libfftw3f.a ; then
+    case $target_host in 
+        i[56]86-*)  cp ../client/win_build/libfftw3f-3-3-4_x86.lib ${XCOMPILE_ROOT}/lib/libfftw3f.a
+                    cp ../client/win_build/libfftw3f-3-3-4_x86.dll ${XCOMPILE_ROOT}/bin
+                    ;;
+        x86*|x64*)  cp ../client/win_build/libfftw3f-3-3-4_x64.lib ${XCOMPILE_ROOT}/lib/libfftw3f.a
+                    cp ../client/win_build/libfftw3f-3-3-4_x64.dll ${XCOMPILE_ROOT}/bin
+                    ;;
+    esac
+  fi
+fi
+
+enables="--enable-static --disable-shared"
+if test $build_client != no ; then
+  enables="${enables} --enable-client"
+else
+  enables="${enables} --disable-client"
+fi
+if test $build_server != no ; then
+  enables="${enables} --enable-server"
+else
+  enables="${enables} --disable-server"
+fi
+
+../configure -C --host=$TARGET_HOST --build=$BUILD_HOST ${enables} --with-ssl=${XCOMPILE_ROOT} --prefix=${XCOMPILE_ROOT}
+make -j 4 all

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-boinc/boinc-app-seti.git



More information about the pkg-boinc-commits mailing list