Aside from the fact that it doesn't compile since you commented out
//MainModule *MM;

You also seem to have removed (or it was never there to begin with) the statement which assigns MM to point to some real memory. As an uninitialised global, it will just be NULL and that'll get you a seg fault every time.