Massive refactor for a new framework