Add casts to ext funcs pointers so that C++ compilers won't complain and fix a couple of wrong return types.