Refactor the code for using a single MongoDB for all graphs

Markus,

Please review the changes made. 

Thanks,
-Ning