Db cleanup and fixes.