much shuffling and refactoring.