Huge refactor. See Changelog.txt