Index: /trunk/ippToPsps/src/Dvo.c
===================================================================
--- /trunk/ippToPsps/src/Dvo.c	(revision 34807)
+++ /trunk/ippToPsps/src/Dvo.c	(revision 34808)
@@ -21,5 +21,7 @@
     if (this->mysql) mysql_close(this->mysql);
 
-    free(this);
+    // libohana redirects free and gets confused by thigns allocated by calloc
+    // so call the real free funtion through this warpper
+    real_free(this);
 }
 
@@ -94,13 +96,13 @@
                 PhotCode *code = GetPhotcodebyCode(meas->photcode);
                 sprintf(sql, 
-                        "INSERT INTO dvoDetection (imageID, ippDetectID, detectID, ippObjID, objID, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES (%d, %u, %lu, %lu, %lu, %u, %f, %f, %f, %f, %lf, %lf, %f %f)",
+                        "INSERT INTO dvoDetection (imageID, ippDetectID, detectID, ippObjID, objID, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES (%d, %u, %lu, %lu, %lu, %u, %f, %f, %f, %f, %lf, %lf, %f, %f)",
                         image->imageID,    // imageID
                         meas->detID,   // ippDetectID
                         meas->extID,   // detectID
                         (uint64_t)ave->catID*1000000000 + (uint64_t)ave->objID, // ippObjID
-                        dvoDetections[i].ave.extID,   // objID
-                        meas->dbFlags,                // flags
+                        ave->extID,   // objID
+                        meas->dbFlags,  // flags
                         code->C * 0.001 + code->K * (meas->airmass - 1) - meas->Mcal,   // zp
-                        meas->dMcal,                  // zpErr
+                        meas->dMcal,    // zpErr
                         meas->airmass,
                         pow(10.0, 0.4 * meas->dt),    // expTime
