Refactored. Made logout show only if authenticated.