Fixed a bug in mms (returns wrong result if whole pattern matched)