Big refactoring round