broke everything again...
further attempts on permutations...
unit test fixed
fixed optimiser
pending files to commited after refactoring
Revert "pending files to commited after refactoring"

This reverts commit 95a066e91036e53e4023a673305a745ab3a62eee.