Corrected a bug where dtime could be equal to zero