Updated mex-dispatch