fixes for #166, calc.derivs; now passes R CMD check