Format code
Correct bug in triples generation logic.