Beginning of massive refactor