Major huge refactor