Improve session functions