Take empty events into account.
Fix mistake with emtpy events vector.