improve sync, fix bugs