Index: /trunk/Ohana/src/opihi/lib.data/MedImageOps.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.data/MedImageOps.c	(revision 41161)
+++ /trunk/Ohana/src/opihi/lib.data/MedImageOps.c	(revision 41162)
@@ -32,7 +32,9 @@
   free (medimage[0].name);
   for (i = 0; i < medimage[0].Ninput; i++) {
-    free (medimage[0].buffers[i]);
+    free (medimage[0].flx[i]);
+    FREE (medimage[0].var[i]);
   }
-  free (medimage[0].buffers);
+  free (medimage[0].flx);
+  free (medimage[0].var);
   free (medimage);
 }
@@ -75,5 +77,6 @@
   medimage->Nx = Nx;
   medimage->Ny = Ny;
-  ALLOCATE (medimage->buffers, float *, 1);
+  ALLOCATE (medimage->flx, float *, 1);
+  ALLOCATE (medimage->var, float *, 1);
 
   medimages[N] = medimage;
Index: /trunk/Ohana/src/opihi/lib.data/SplineOps.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.data/SplineOps.c	(revision 41161)
+++ /trunk/Ohana/src/opihi/lib.data/SplineOps.c	(revision 41162)
@@ -41,7 +41,9 @@
     ALLOCATE (spline[0].y2, opihi_flt, spline[0].Nknots);
   }
-  memset (spline[0].xk, 0, spline[0].Nknots * sizeof(opihi_flt));
-  memset (spline[0].yk, 0, spline[0].Nknots * sizeof(opihi_flt));
-  memset (spline[0].y2, 0, spline[0].Nknots * sizeof(opihi_flt));
+  if (spline[0].Nknots) {
+    memset (spline[0].xk, 0, spline[0].Nknots * sizeof(opihi_flt));
+    memset (spline[0].yk, 0, spline[0].Nknots * sizeof(opihi_flt));
+    memset (spline[0].y2, 0, spline[0].Nknots * sizeof(opihi_flt));
+  }
 }
 
Index: /trunk/Ohana/src/opihi/lib.data/open_kapa.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.data/open_kapa.c	(revision 41161)
+++ /trunk/Ohana/src/opihi/lib.data/open_kapa.c	(revision 41162)
@@ -266,4 +266,5 @@
 int close_kapa (char *name) {
 
+  struct timespec request, remain;
   int N;
 
@@ -274,4 +275,24 @@
   }
   DelKapaDevice (name);
+
+  // avoid blocking on waitpid, test every 1 msec, up to 500 msec
+  request.tv_sec = 0;
+  request.tv_nsec = 1000000;
+
+  // try to harvest the child PID
+  int waitstatus = 0;
+  int result = waitpid (-1, &waitstatus, WNOHANG);
+  for (int i = 0; (i < 500) && (result == 0); i++) {
+    nanosleep (&request, &remain);
+    result = waitpid (-1, &waitstatus, WNOHANG);
+  }
+
+  if ((result == -1) && (errno != ECHILD)) {
+    fprintf (stderr, "unexpected error from waitpid (%d): programming error\n", errno);
+  }
+  if (result == 0) {
+    fprintf (stderr, "child did not exit (close_kapa), timeout");
+  }
+
   return (TRUE);
 }
Index: /trunk/Ohana/src/opihi/lib.data/spline.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.data/spline.c	(revision 41161)
+++ /trunk/Ohana/src/opihi/lib.data/spline.c	(revision 41162)
@@ -7,4 +7,7 @@
   float dy, dx, *tmp;
   
+  // spline is not valid with < 3 points
+  if (N < 3) return;
+
   ALLOCATE (tmp, float, N);
 
@@ -69,4 +72,7 @@
   opihi_flt dy, dx, *tmp;
   
+  // spline is not valid with < 3 points
+  if (N < 3) return;
+
   ALLOCATE (tmp, opihi_flt, N);
 
Index: /trunk/Ohana/src/opihi/lib.data/starfuncs.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.data/starfuncs.c	(revision 41161)
+++ /trunk/Ohana/src/opihi/lib.data/starfuncs.c	(revision 41162)
@@ -75,4 +75,6 @@
   FWHMx = 2.355*sqrt (fabs(x2 / I - x*x));
   FWHMy = 2.355*sqrt (fabs(y2 / I - y*y));
+
+  fprintf (stderr, "Mxx, Myy: %f, %f\n", x2/I - x*x, y2/I - y*y);
   Sxy   = xy / I - x*y;
   mag = -2.5*log10(I);
Index: /trunk/Ohana/src/opihi/lib.data/style_args.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.data/style_args.c	(revision 41161)
+++ /trunk/Ohana/src/opihi/lib.data/style_args.c	(revision 41162)
@@ -72,4 +72,14 @@
   }
 
+  if ((graphmode[0].style == KAPA_PLOT_POLYGON) || (graphmode[0].style == KAPA_PLOT_POLYFILL)) {
+    if ((N = get_argument (*argc, argv, "-npoint"))) {
+      remove_argument (N, argc, argv);
+      graphmode[0].ptype = atoi (argv[N]);
+      remove_argument (N, argc, argv);
+    } else {
+      gprint (GP_ERR, "polygon & polyfill styles require number of points argument: -npoint N\n");
+      return FALSE;
+    }
+  }
   return (TRUE);
 }
