Adding some subsetting optimization code I've been working on.