more pruning and refactoring.