Changes corresponding to fix for mongoose #2143