Typechecking: phase 2.1, bug fixes