converting menu commands into common code, moving more code to model.