Did some refactoring.  Next up, write tests and delete unused code