Fix a couple of issues with replication