zIndex error on overlay

For some reason, the overlay gets an z-index of 1001.
This is far more than all parents z-indexes.

So an additional check for the z-index is added.