port across mongo improvements from elasticsearch branch