Port "logdiff" objective function from r21 to main
or think about the alternative