Massive refactor to split tables