Mongodb support

Merging branch with mongodb functionality to add this funtionality to master.