typecheck improvements