In particular, this fixes a detrending bug in relation to the Occbin engine. Closes: #1827 (manually cherry picked from commit f22dff35)