Refactoring including factoring code, comments, and cleaning imports