OAuth2 bug fixes and handle errors better