Adding query count tracking.