Fix issue #47 - Better algorithm for serialize diffs

Closes #47