Overhaul typechecking for patterns