Added a few changes to the event logic.