Refactoring

Cleaning up some of the code.