Long Term Evolution of Planetary Systems