fix eeendless bugs with apply.fun. Benchmarked the improved version against lapply - 400-500s difference operating on 1m rows.