Issue #339 - Minor restructuring of SessionThemeProvider class.

No functional changes.
Just extract local variables so it is easier to debug what could lead to NPE in case it occurs