Made some code faster in places where we only need the size of the records returned. Take the count directly from the cursor returned instead of turning the cursor into an array first and taking the length.