A final refactoring pass