typechecker improvements, and made node union access safe