Fix overlay zindex issues

This follows work done in #1120 and fix some z-index issues with overlays.

Note that this pr depends on #1120 which should be merged first.