Big refactor!