Added error handling for stale sessions.