Major refactoring in preparation for 1.1 release