Refactored namespace and logout functionality