mat: modernisation

Modernises the MAT formula a little, especially around the handling of the Python elements.
@mistydemeo gonna go for `:optional` if that's OK then.