Refactoring to remove friend functions.