Completed first pass at refactor.