Alert threshold for checkevents

Rebase of #86 + refactoring