reorganization and clean up, not quite working