Cleaned up some log-in logic, and added log-out functionality.