Refactored login code and added support for google login.