mm bug fixes and loop change