fix multi-index detection in _ensure_index
groupby optimizations