adding slightly improve sync code. Fixed typos.