fix some replication bugs