Further improvements in login logic