Started potential refactoring

Will refactor in another branch.