Refactor all metatheory except type soundness