Local copy of g2tog1