Added some functions.
Session close fixes.
Added session close test.