The structure and dynamical evolution of dark matter haloes