Fix various bugs in the new syncing script