Fix nasty bug that made the client sometimes crash at sync.