General cleanup of session

There are a number of issues flagged by code analysis.  None of them
are functional, but change to be happier by code analysis.

Change-Id: Id1c2fb9c32c1f7f45cc7cad77c09fb55fb40a8a3