Fixes related to last change: Refactor and start implementation of ES based events query