Db related bug fixes.