Update rugged diff support

Here's the code i had in the other PR (#1) that i applied to this branch to make it easier to review and work on.