Fix autologin loop, add login rate limiting, and don't login unless necessary