somewhat large refactoring; top-level interfaces make much more sense now