move debug output to console.log; make DB upgrade work more reasonably