Bringing some menu-related code to higher quality.