Refactor.
Refactor.
Fix handling of redirects.