improve versatility and performance of Codec API