Refactoring code with suggestions and removing unused library