Improve clearing old diff information

It should be cleared just before updating diff information.
Fix doc-string
Refactoring