Fix bugs in synchronize