Merge erkristen's replicaset rewrite