New session_name function, bugfixes