Issue #166: More count() improvement