Big refactoring done.