Some basic refactoring done.