Fix patch creation

Handle modified lines at end of file
Improve diff view scrolling