Intial work on refactoring.