ISSUE #34: Fix excessive number of query size() calls