Reorder some functions in typecheck