Major refactoring/redesign.