Magnetic excitations and dynamical Jahn-Teller distortions in UO2