Some basic refactoring.