Cleaned up the login functionality somewhat