Fix encoding to allow ? and # in the redirect url.  Move interface to own file.