Small Db class fixes plus some output fixes/changes

Couldn't separate these otherwise I'd only have done the Db fixes. Pull into a branch and cherry pick ;-)