Issues #3427: Fix some bugs in event system