Merge changes I50dcec81,Ieab28bb3

* changes:
  Fix empty block corner case in PatienceDiff
  Fix infinite loop in PatienceDiff