More use of native matrix functions