session handling fixes