Improved session handling