Fix error and make alerts show

Access to nonexisting event data did make the errors not to show up.
Reordered the lines so that error events are checked first.