Better checks on the input type to the mex functions.