Fixed the login/logout functionality properly.
Fixed up the permission management a little.