General reorganization and cleanup