Refactoring part 1 of 2.