Tests passing, more refactoring