assorted refactoring before namespace rearrangement