During recent years, the theory of charged particle optics together with advances in fabrication tolerances and experimental techniques has lead to very significant advances in high-performance electron microscopes. Here, we will describe which theoretical tools, inventions and designs have driven this development. We cover the basic theory of higher-order electron optics and of image formation in electron microscopes. This leads to a description of different methods to correct aberrations by multipole fields and to a discussion of the most advanced design that take advantage of these techniques. The theory of electron mirrors is developed and it is shown how this can be used to correct aberrations and to design energy filters. Finally, different types of energy filters are described.Invited paper.