Code is refactored

Some commonly used functions and types are moved from menu to settings.
These functions and types are more general than menu so they can be used
in other modules.