The scope of this paper is to provide clarity over fundamental effects of non-axisymmetric endwall contouring in a highly-loaded compressor tandem stator. Specifically, the focus of the research will be the influence that aerofoil optimization and end-wall contouring have on each other, and how a combined optimization of the two simultaneously affects the final design of the optimized geometry. The reference geometry used in this research is a standard tandem vane arrangement with smooth axi-symmetric endwalls and designed to represent a datum stage configuration for future investigations of such blade geometries, experimental work on a low-speed research compressor being a next step. The optimization was performed using an in-house developed routine coupled with Auto-Opti, an automated optimizer based on an evolutionary strategy algorithm, developed by the DLR Institute of Propulsion Technology. The entire optimization was conducted solely on the stator, modeled as an annular cascade. This paper reports about a thorough flow field analysis of the optimized geometry in order to understand local mechanisms occurring with non-axisymmetric contouring in the tandem stator passage flow field and its overall performance. Furthermore, it describes and explains the effect that the aerofoil optimization has on the contoured hub surface shape, compared to an optimization process, which is only applied to the hub contouring. In particular, the results clarify how endwall flow field improvements reduce the degree of required aerofoil deformation, and show that the new blade shape is better adapted to the contoured endwall. The 3D endwall flow field has been investigated in order to understand how the optimized geometry modifies the magnitude of the cross-passage flow and reduces the size of the trailing edge corner vortex of the front and rear tandem vane. The paper concludes with some guidelines on how endwall contouring and near endwall aerofoil section design and optimization can be applied most effectively.