Fixed few issues in db.scm. NOTE: these might also be problems in v1.65