Update mm.c

fix run time bugs. But still some performance errors.