event/main.py: use groupIterById to prevent critical bugs, and some cleaning