Improved session and login handling.