Fixed bug where queries against main collection that returned empty set were causing the functions that calculate the totals to fail.