Fixing Triples query generator.