Fixes to login code