Fix rounding errors in timer handling