Added workaround for REDIRECT_STATE and urlencoding.