Updated with changes added in mongoose branch