As semiconductor lithography is pushed to smaller dimensions, the process yields tend to suffer due to subwavelength imaging effects. In response, resolution enhancement technologies have been employed together with optimization techniques, specifically source mask optimization (SMO), which finely tunes the process by simultaneously optimizing the source shape and mask features. However, SMO has a limitation in that it fails to compensate for undesired phase effects. For mask features on the order of the wavelength, the topography of the mask can induce aberrations which bring asymmetry to the focus-exposure matrix (FEM) and ultimately decrease the process window. This paper examines the dependency of FEM asymmetry on factors such as the illumination coherency and lens induced spherical aberration. It is shown that lens induced primary spherical aberration strongly impacts the symmetry of the FEM. In this work, phase correction is achieved by incorporating the pupil plane in an optimization. It is shown that primary spherical aberration can correct for effects including the degraded depth of focus and the tilt in the FEM for a dual trench mask. A pupil function with an optimized coefficient of primary spherical aberration balances the spherical aberration induced by the mask topography.