added mongodb support and some fixes