  Point Spread Function (PSF) engineering is used in single emitter
localization to measure the emitter position in 3D and possibly other
parameters such as the emission color or dipole orientation as well. Advanced
PSF models such as spline fits to experimental PSFs or the vectorial PSF model
can be used in the corresponding localization algorithms in order to model the
intricate spot shape and deformations correctly. The complexity of the optical
architecture and fit model makes PSF engineering approaches particularly
sensitive to optical aberrations. Here, we present a calibration and alignment
protocol for fluorescence microscopes equipped with a spatial light modulator
(SLM) with the goal of establishing a wavefront error well below the
diffraction limit for optimum application of complex engineered PSFs. We
achieve high-precision wavefront control, to a level below 20 m$\lambda$
wavefront aberration over a 30 minute time window after the calibration
procedure, using a separate light path for calibrating the pixel-to-pixel
variations of the SLM, and alignment of the SLM with respect to the optical
axis and Fourier plane within 3 $\mu$m ($x/y$) and 100 $\mu$m ($z$) error.
Aberrations are retrieved from a fit of the vectorial PSF model to a bead
$z$-stack and compensated with a residual wavefront error comparable to the
error of the SLM calibration step. This well-calibrated and corrected setup
makes it possible to create complex `3D+$\lambda$' PSFs that fit very well to
the vectorial PSF model. Proof-of-principle bead experiments show precisions
below 10~nm in $x$, $y$, and $\lambda$, and below 20~nm in $z$ over an axial
range of 1 $\mu$m with 2000 signal photons and 12 background photons.
