It doesn't appear that functions like `idig_count_records` can be vectorized. This is crucially important, especially on large datasets. Determine the best way to apply the functions to vectors, or modify the functions.