Various changes

Only use one connection to MongoDB, and allow for authenticated connections. Also let the user specify the directory within the repository containing the rules.