Refactored data collection code to afford better concurrency.