Some light refactoring.