PatternExpander moved; typecheckTree changed to remove side effect