Fixed bug where original URI wasn't getting computed correctly and redirects weren't handled cleanly