Small db refactor