Sometimes, the fitting is applied the wrong way on the samples. Instead of interpreting the signal as having a positive amplitude, it supposes the signal as having a negative amplitude. This means that the phase shift is computed differently. We can then observe an error of a multiple of half a period of the signal frequency on the measured delay. This is, for the moment, corrected on a case by case basis by analysing the phase and amplitude sign and removing or adding a corresponding correction to the measured delay. This unfortunately does not work every time and a deeper study is required to solve that issue.