fixed some improper use of mongodb driver causing memory errors