added mex use potential flag
re included debug funcs