Improve v3 auth support.

refactor to better support v3 auth.
more pep8 work.