implement 'cleanup' and 'diff'