Calculate document counts on background thread (ref #118)