Sped up and corrected diff processing edge cases.