Debugged calculation of number of epochs.