WIP: Refactor libs

DO NOT MERGE

I'm trying to clean up the `configure_replicaset` and `configure_shards` methods. This PR is just for others to review. Even when it is actually close to being well factored, it will need to be entirely rewritten to ensure backward compatibility.