Code cleaned up.

Is also updated in order to adjust for Mwlibrary changes.