Some internal optimizations for subsetting; used in the summary statistics calculations.