Fixed some issues with typechecking.