Refactor in preparation for supporting GMP types