WIP Gigantic refactoring and cleaning... Really.