File reorganization and refactoring