Reorganize menu code.