fixed issue 1251, imporved mongodb support, thanks Alan