Improved popup and overlay positioning.