Complete refactoring. All tests passed.