fixing bug in mex_helper: actually count number of fields in a struct
remove stringstream use for compatibility with Mac