Reorganization, refactoring, and cleanup