Rewrite internal Pair type in C to gain more performance