Fix 2 bugs to make replicaset works