Added error checking when syncing.