some fixes to session handling