Address a few bugs in handling large record sets

There are some miscellaneous one line patches here. Broken into several commits to make review easier. More could be done to handle large result sets, but these changes unblocked me with the current project I'm on, which contains a few hundred thousand rows and tens of thousands of rows per record.