Huge refactoring...now we just need better test coverage