Added logged-in parameter where needed, and support for logging out.
Logout function doesn't return anything.