Refactoring

Started refactoring on new branch