Started optimization work but also fixed a multithreading issue.
More optimizations avoid generating non nesecarry triples before
filtering.