Update .gitignore to correctly ignore *~ files.
Add more tests for fixing overlaps.