Some reorganization and cleanup