Restructured monoid implementations a bit.