Changed objfun to call C funcs for distrand