Refactor out the syncing stuff