Fix bugs in replicating locally.