v4 refactor for diff() support