Inital work on refactoring