[ISSUE-66918282] fix bugs for long-polling
diff --git a/api.go b/api.go
index f271370..b6e3449 100644
--- a/api.go
+++ b/api.go
@@ -66,6 +66,7 @@
 
 const (
 	headerSteam           = "application/octet-stream"
+	headerJson            = "application/json"
 	apidConfigIndexPar    = "apid-config-index"
 	apidConfigIndexHeader = "x-apid-config-index"
 )
@@ -343,11 +344,11 @@
 		return
 	}
 
-	log.Debugf("sending deployments %s: %s", apidLSN, b)
 	if apidLSN != "" {
 		w.Header().Set(apidConfigIndexHeader, apidLSN)
 	}
-
+	w.Header().Set("Content-Type", headerJson)
+	log.Debugf("sending deployments %s: %s", apidLSN, b)
 	w.Write(b)
 }
 
diff --git a/bundle.go b/bundle.go
index 64e1e69..537777a 100644
--- a/bundle.go
+++ b/bundle.go
@@ -310,7 +310,6 @@
 func downloadFromURI(client *http.Client, blobServerURL string, blobId string) (tempFileName string, err error) {
 
 	var tempFile *os.File
-	log.Debugf("Downloading Blob: %s", blobId)
 
 	uri, err := getSignedURL(client, blobServerURL, blobId)
 	if err != nil {
diff --git a/data.go b/data.go
index 37da7c2..1a6d014 100644
--- a/data.go
+++ b/data.go
@@ -345,6 +345,7 @@
 }
 
 func (dbc *dbManager) loadLsnFromDb() error {
+	log.Debug("loadLsnFromDb")
 	var LSN sql.NullString
 	ret := InitLSN
 
@@ -356,7 +357,7 @@
 	}
 	if LSN.Valid {
 		ret = LSN.String
-		log.Debugf("LSN from APID_CONFIGURATION_LSN: %s", LSN)
+		log.Debugf("LSN from APID_CONFIGURATION_LSN: %s", LSN.String)
 	}
 	dbc.lsnMutex.Lock()
 	defer dbc.lsnMutex.Unlock()
diff --git a/listener.go b/listener.go
index dc7eaaf..8f00d0f 100644
--- a/listener.go
+++ b/listener.go
@@ -70,22 +70,27 @@
 	log.Debugf("Snapshot received. Switching to DB version: %s", snapshot.SnapshotInfo)
 
 	h.dbMan.setDbVersion(snapshot.SnapshotInfo)
+	err := h.dbMan.initDb()
+	if err != nil {
+		log.Panicf("unable to init DB: %v", err)
+	}
 
-	h.startupOnExistingDatabase()
 	if lsn := h.dbMan.getLSN(); lsn != "" {
 		h.dbMan.updateLSN(lsn)
 	} else { //apid just started
 		h.dbMan.loadLsnFromDb()
 	}
+	h.startupOnExistingDatabase()
 	h.apiMan.InitAPI()
 	log.Debug("Snapshot processed")
 }
 
 func (h *apigeeSyncHandler) startupOnExistingDatabase() {
 	// start bundle downloads that didn't finish
+
 	go func() {
 		// create apid_blob_available table
-		h.dbMan.initDb()
+
 		blobIds, err := h.dbMan.getUnreadyBlobs()
 
 		if err != nil {
@@ -96,6 +101,7 @@
 		for _, id := range blobIds {
 			go h.bundleMan.enqueueRequest(h.bundleMan.makeDownloadRequest(id, nil))
 		}
+
 	}()
 }