diff --git a/includes/DrupalOAuthRequest.inc b/includes/DrupalOAuthRequest.inc
index dce9158..c010735 100644
--- a/includes/DrupalOAuthRequest.inc
+++ b/includes/DrupalOAuthRequest.inc
@@ -13,44 +13,15 @@ class DrupalOAuthRequest extends OAuthRequest {
   public static function from_request($http_method = NULL, $http_url = NULL, $parameters = NULL) {
     // Preparations that has to be made if we're going to detect parameters
     if ($parameters == NULL) {
+      // The QUERY_STRING might be messed up by rewriting the URL (ie. for clean urls).
       $qs = $_SERVER['QUERY_STRING'];
-      $q = $_GET['q'];
-
-      // Unset $_GET['q'] if it was created by a redirect
-      if (isset($_SERVER['REDIRECT_URL'])) {
-        $q = FALSE;
-      }
-      // Check that the q parameter hasn't been created or altered by drupal
-      elseif (isset($_GET['q'])) {
-        $get = array();
-        parse_str($_SERVER['QUERY_STRING'], $get);
-        // The q parameter was in the original request, make sure it hasn't been altered
-        if (isset($get['q'])) {
-          $q = $get['q'];
-        }
-        // The q parameter was set by drupal, unset it
-        else {
-          $q = FALSE;
-        }
-      }
-
-      $parsed = array();
-      parse_str($_SERVER['QUERY_STRING'], $parsed);
-      if ($q === FALSE) {
-        unset($parsed['q']);
-      }
-      else {
-        $parsed['q'] = $q;
-      }
-      $_SERVER['QUERY_STRING'] = http_build_query($parsed, '', '&');
-    }
-    $req = parent::from_request($http_method, $http_url, $parameters);
-
-    // Restore $_SERVER['QUERY_STRING'] if it was touched
-    if (isset($qs)) {
+      $parts = explode($_SERVER['REQUEST_URI'], '?', 2);
+      $_SERVER['QUERY_STRING'] = count($parts) >= 2 ? $parts[1] : '';
+      $req = parent::from_request($http_method, $http_url, $parameters);
       $_SERVER['QUERY_STRING'] = $qs;
+      return $req;
+    } else {
+      return parent::from_request($http_method, $http_url, $parameters);
     }
-
-    return $req;
   }
 }
