Extract the menu creation and add debug support