lots of refactoring.