Reorganize type checking