Minor refactoring in preparation for modules