Further refactoring and addition of classes.
Completed first round refactoring