We're also assuming that the events are sorted by timestamp (which they are, but maybe we should write it as a comment or something)