Fix function type checking. Typechecker now passes all local tests