Modal generalization

Modal Generalizations to enable other plugins to use the modal.
Also cherry-picked @GarstgerUnhold bugfix.
This might still need work. If you want to merge this, proceed with caution!