Nekhoroshev and KAM Stabilities in Generalized Hamiltonian Systems