Fixed issue #257 - Reset client sync on error

Closes #257
put all of this in a function for consistency