Refactoring and cleaning