Improved monoid implementation for quotations