Fixing some bugs with sessions