improved pymongo connection etc