[9.16] Keep the list of scheduled events on the timer
Instead of searching for the events to purge, keep the list of scheduled events on the timer list and purge the events that we have scheduled.
Backport of MR !6053 (merged)
Closes #3252 (closed)
Edited by Michał Kępień