Tweaks to session state saving and restoring
Better shutting down of apps on session end.