Some brief changes to add more result->close() calls, trying to lessen the load on the database.