Use ArrayLists instead of LinkedLists. Now it's faster.
Algorithmic gains! Skip generating partitions that have equal parts.
Skip generating partitions which we know will be too long. Large speedups for small M.