mat: modernisation

Modernises the MAT formula a little, especially around the handling of the Python elements.
Pushing now with ``` :optional ```. Happy to change as necessary/desired.