Fix the crashing of visible events from Modals

Added a defensive code to prevent crashes on the visible events of Modal and Collapse.

Also changed the packaged o HasVisibleHandlers to the package event (the right place).