Fixes to the sync algorithm.