Fixed bugs in sync