Major refactoring, some redesign.