Reduced code duplication in menu code.