Parallel processing should be added particularly to the resampling process. The custom agg functions are very likely the major time sink.