Further improvements to subset. Eliminated unnecessary array allocations.