Big refactor! :p