Fix several sync bugs