several replication bug fix