major refactoring in preparation for dominion