did a bunch of refactoring and cleaned up code