DB refactor