Fix resyncing unnecessarily on windows machines.
Simplified the replacing method.
Rearranged the location of the sort function.
PEP8 formatting.
Merge pull request #865 from kyleknap/resync_bug

Fix resyncing unnecessarily on windows machines.