Refactoring and cleaning of code