fix some bugs re: empty dbs.