Refactor

Can continue refactoring on master branch