Fix duplicate event handlers bug