Database & architecture refactoring