Fix elapsed time overflowing incorrectly

Thanks to lavia-ale for reporting it.