Remove hard dependency on mongodb

Fix for #376 and partially #382.