Bugfix and added Logout function