Fix undefined event, add check prior to delete