Fix batching for calculations.

Needs a guard for dividing by 0