Some basic refactoring