Improve tracking of login state