Cleaning
Refactoring and tests