Fix various bugs in groupings/selectors.