Fix invalid event handler removal