  (abridged) Even if the HARPS spectrograph has been operational for more than
15 years and it provides among the most precise Doppler measurements,
improvements are still possible. One known problem, for instance, is the
non-fully regular block-stitching of the CCDs, which introduces, in some cases,
one-year period parasitic signals in the measured radial velocity.
  The aim is to improve the wavelength calibration of HARPS to push further its
planet-detection capabilities.
  The properties of the CCD stitching-induced pixel-size anomalies are
determined with LED flat-field frames, and then a physical, gap-corrected map
of the CCDs is used for the fitting model of the spectral orders. We also use a
new thorium line list, based on much higher-accuracy measurements than the one
used up to now. We derive new wavelength solutions for the 15 years of HARPS
data, both before and after the 2015 fibre upgrade.
  We demonstrate that we correct the gap anomalies by computing the wavelength
solutions of laser frequency comb exposures, both with and without taking the
gap correction into account. By comparing the rms of the most stable stars of
the HARPS sample, we show that we globally decrease the radial velocity
dispersion of the data, especially for the data acquired after the change of
fibres. Finally, the comparative analysis of several individual systems shows
that we manage to attenuate the periodogram power at one year in most cases.
The analysis of the RVs derived from individual stellar lines also shows that
we correct the stitching-induced RV variation.
  This improved calibration of the HARPS spectrograph allows to go deeper in
the search for low-amplitude radial-velocity signals. It will be further
improved by combining the thorium calibration spectra with laser frequency comb
and Fabry-Perot calibration spectra, and not only for HARPS but notably also
for HARPS-N and ESPRESSO.
