Fix occasional exception in diff handling