Fixing bugs related to events