Add checking of permissions when processing events. Fix incorrect logic for belated events.