Index: trunk/ippTools/src/pzgetexpConfig.c
===================================================================
--- trunk/ippTools/src/pzgetexpConfig.c	(revision 6837)
+++ trunk/ippTools/src/pzgetexpConfig.c	(revision 6876)
@@ -21,22 +21,30 @@
         "telescope name", "");
 
-    bool argErr = false;
-    if (! psArgumentParse(args, &argc, argv) || argc != 2) {
-        argErr = true;
-        fprintf (stderr, "error parsing arguments\n");
-    }
-
-    if (argErr) {
+    bool status = false;
+    if (!psArgumentParse(args, &argc, argv)
+        || argc != 1
+        || strcmp(psMetadataLookupStr(&status, args, "-uri"), "") == 0
+        || strcmp(psMetadataLookupStr(&status, args, "-inst"), "") == 0
+        || strcmp(psMetadataLookupStr(&status, args, "-telescope"), "") == 0
+    ) {
+        fprintf(stderr, "error parsing arguments\n");
         printf("\nPan-STARRS Phase Z Search Tool\n");
         printf("Usage: %s -uri -inst -telescope\n\n", argv[0]);
         psArgumentHelp(args);
-        psFree(args);
+        psFree(config);
         exit(EXIT_FAILURE);
     }
 
     config->args = args;
+    // don't free args here as it's silly to increment the ref count then
+    // "free" it
 
     // define Database handle, if used
     config->dbh = pmConfigDB(config->site);
+    if(!config->dbh) {
+        psError(PS_ERR_UNKNOWN, false, "Can't connect to db\n");
+        psFree(config);
+        exit(EXIT_FAILURE);
+    }
 
     return config;
