Fixed some issues for mongodb