Fixing incorrect session handling