Refactoring DB management