Fixed a few bugs with the sync script.