Refactor overlays view code