Fix data race in evaluation of negative log marginal likelihood derivatives

Quick fix for #1693, #1694, #1695 and #1696.