more DB refactoring