Lots of reorganization to support new functionality