Massive refactor!