Code refactoring and documenting