slightly more robust mex argument handling