Complete sync function.

1. Complete sync function.
2. Fix some bugs.

Signed-off-by: ycchen <ytu_cyc@126.com>