Starting code refactor.
Finished refactoring.