Redo PMP's patch to rewriting to make it purely functional using state passing.
Add interface function to replace new_Type ()