Fix MongoDB storage

I've cherrypicked my changes and fixes from #82. 

Best,

Julien