Merge "Improve the code of handleSessionLost()"