various cleanup and reorganization