fix some issues with the sync code