Triplets API bugfixed and refactored