fixed some issues in replication