Added possibility to log out and improved login/logout functionality