I believe I solved it myself. The problem was that dt was the time to the last event, but it should be adjusted to the last draw instead. Changing that fixed it.