Averaging Hamiltonian Systems