Major refactoring effort.