further optimizations in deriv