Fixes to support better replicaset handling