Improve session handling