Correctly handle redirects

Fixes #2