improvements to modal event handling