Fix for SessionException.
Refactoring and improvements to SessionHelper (work in progress).