major db refactor