Session refactoring, fixes, tidy up