The structure of the wave operators in four dimensions in the presence of resonances