added params to swtdetect.c. Tried to add memory freeing to mex file