Some Db related refactoring