Removed not closing overlay if the the click target isn't the overlay. Added checking if the overlay is hidden before showing and hiding.