Few optimisations: caching for splitting only by unique rules attribute-predicate-pivot + removed redundant checking (because of pretty JS behaviour for undefined variables)