diff: Backtrack from end of string and some small optimisations