Some refactoring in preparation for 1.2