Fixes to login system