Fixed a few bugs around sessions.