Added some handling for events