Some refactoring to take advantage of OAuth2 submodule improvements