Added back mongodb, refractored some code