some refactoring of diff hunk reading code