diff --git a/httprl.module b/httprl.module
old mode 100644
new mode 100755
index 665f736..5a92ec3
--- a/httprl.module
+++ b/httprl.module
@@ -6,22 +6,64 @@
  */
 
 /**
+ * Error code indicating that the request made by httprl_request() exceeded
+ * the maximum allowed redirects without reaching the final target.
+ */
+define('HTTPRL_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED', -2);
+
+/**
+ * Error code indicating that the request made by httprl_request() exceeded
+ * the maximum allowed redirects without reaching the final target.
+ */
+define('HTTPRL_REQUEST_FWRITE_FAIL', -3);
+
+/**
  * Error code indicating that all requests made by httprl_send_request()
  * exceeded the specified timeout.
  */
-define('HTTP_FUNCTION_TIMEOUT', -3);
+define('HTTPRL_FUNCTION_TIMEOUT', -4);
 
 /**
  * Error code indicating that this request made by stream_select() couldn't
  * open a read and/or write steam after a minimum of ~2.5 seconds.
  */
-define('HTTP_STREAM_SELECT_TIMEOUT', -4);
+define('HTTPRL_STREAM_SELECT_TIMEOUT', -5);
+
+/**
+ * parse_url() was unable to parse the given url.
+ */
+define('HTTPRL_URL_PARSE_ERROR', -1001);
+
+/**
+ * Given URL is missing a schema (http, https, feed).
+ */
+define('HTTPRL_URL_MISSING_SCHEMA', -1002);
+
+/**
+ * Invalid schema. Only http, feed, and https allowed currently.
+ */
+define('HTTPRL_URL_INVALID_SCHEMA', -1003);
+
+/**
+ * An error occurred before the system connect() call. This is most likely due
+ * to a problem initializing the stream.
+ */
+define('HTTPRL_ERROR_INITIALIZING_STREAM', -1004);
+
+/**
+ * Error code indicating that the request exceeded the specified timeout.
+ *
+ * @see http://msdn.microsoft.com/en-us/library/aa924071.aspx
+ */
+define('HTTPRL_REQUEST_TIMEOUT', -10060);
 
 /**
  * Error code indicating that the endpoint server has refused or dropped the
  * connection.
+ *
+ * @see http://msdn.microsoft.com/en-us/library/aa924071.aspx
  */
-define('HTTP_CONNECTION_REFUSED', -5);
+define('HTTPRL_CONNECTION_REFUSED', -10061);
 
 /**
  * Implement hook_menu().
@@ -161,7 +203,7 @@ function httprl_build_url_self($path = '', $detect_schema = FALSE) {
  *     may be followed. Defaults to 3.
  *   - timeout: A float representing the maximum number of seconds a connection
  *     may take. The default is 30 seconds. If a timeout occurs, the error code
- *     is set to the HTTP_REQUEST_TIMEOUT constant.
+ *     is set to the HTTPRL_REQUEST_TIMEOUT constant.
  *   - context: A context resource created with stream_context_create().
  *   - blocking: set to FALSE to make this not care about the returned data.
  *   - version: HTTP Version 1.0 or 1.1. Default is 1.0 for a good reason.
@@ -173,7 +215,7 @@ function httprl_build_url_self($path = '', $detect_schema = FALSE) {
  *     be open on the server. Default is 128.
  *   - global_timeout: A float representing the maximum number of seconds the
  *     function call may take. The default is 30 seconds. If a timeout occurs,
- *     the error code is set to the HTTP_FUNCTION_TIMEOUT constant. Default is
+ *     the error code is set to the HTTPRL_FUNCTION_TIMEOUT constant. Default is
  *     120 seconds.
  *   - chunk_size_write: max size of what will be written in fwrite().
  *   - chunk_size_read: max size of what will be read from fread().
@@ -190,7 +232,7 @@ function httprl_request($url, $options = array()) {
 
   if (empty($uri)) {
     $result->error = 'unable to parse URL';
-    $result->code = -1001;
+    $result->code = HTTPRL_URL_PARSE_ERROR;
 
     // Add in failed request to the output.
     // Exit if the URL passed in is bad.
@@ -199,7 +241,7 @@ function httprl_request($url, $options = array()) {
 
   if (!isset($uri['scheme'])) {
     $result->error = 'missing schema';
-    $result->code = -1002;
+    $result->code = HTTPRL_URL_MISSING_SCHEMA;
 
     // Add in failed request to the output.
     // Exit if no scheme was passed in.
@@ -255,7 +297,7 @@ function httprl_request($url, $options = array()) {
       break;
     default:
       $result->error = 'invalid schema ' . $uri['scheme'];
-      $result->code = -1003;
+      $result->code = HTTPRL_URL_INVALID_SCHEMA;
 
       // Add in failed request to the output.
       // Exit if an invalid scheme was passed in.
@@ -315,8 +357,8 @@ function httprl_request($url, $options = array()) {
     if (!$errno) {
       // If $errno is 0, it is an indication that the error occurred
       // before the connect() call. This is most likely due to a problem
-      // initializing the socket.
-      $result->code = -1004;
+      // initializing the stream.
+      $result->code = HTTPRL_ERROR_INITIALIZING_STREAM;
       $result->error = !empty($errstr) ? $errstr : t('Error initializing socket @socket', array('@socket' => $socket));
     }
     else {
@@ -445,27 +487,6 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
   $timer_name = mt_rand();
   timer_start($timer_name);
 
-  if (defined('HTTP_REQUEST_TIMEOUT')) {
-    $http_request_timeout = HTTP_REQUEST_TIMEOUT;
-  }
-  else {
-    $http_request_timeout = -1;
-  }
-  if (defined('HTTP_REQUEST_FWRITE_FAIL')) {
-    $http_request_fwrite_fail = HTTP_REQUEST_FWRITE_FAIL;
-  }
-  else {
-    $http_request_fwrite_fail = -2;
-  }
-  // HTTP_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED is defined in
-  // http://drupal.org/node/1096890
-  if (defined('HTTP_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED')) {
-    $http_request_allowed_redirects_exhausted = HTTP_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED;
-  }
-  else {
-    $http_request_allowed_redirects_exhausted = 2;
-  }
-
   // Run the loop as long as we have a stream to read/write to.
   $empty_runs = 0;
   $stream_select_timeout = 1;
@@ -487,7 +508,7 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
         else {
           $responses[$id]->error = 'request timed out';
         }
-        $responses[$id]->code = $http_request_timeout;
+        $responses[$id]->code = HTTPRL_REQUEST_TIMEOUT;
         $responses[$id]->status = 'Done.';
         $responses[$id]->options['timeout'] = $timeout;
         fclose($fp);
@@ -505,7 +526,7 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
         else {
           $responses[$id]->error = 'function timed out';
         }
-        $responses[$id]->code = HTTP_FUNCTION_TIMEOUT;
+        $responses[$id]->code = HTTPRL_FUNCTION_TIMEOUT;
         $responses[$id]->status = 'Done.';
         $responses[$id]->options['timeout'] = $global_time;
         fclose($fp);
@@ -521,8 +542,8 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
             // If stream is not done writing, then remove one from the write count.
             $stream_write_count--;
           }
-          $responses[$id]->error = 'connection refused/dropped';
-          $responses[$id]->code = HTTP_CONNECTION_REFUSED;
+          $responses[$id]->error = 'Connection refused by destination';
+          $responses[$id]->code = HTTPRL_CONNECTION_REFUSED;
           $responses[$id]->status = 'Done.';
           $responses[$id]->options['timeout'] = $timeout;
           fclose($fp);
@@ -662,7 +683,7 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
           if ($bytes === FALSE) {
             // fwrite failed.
             $responses[$id]->error = 'fwrite failed';
-            $responses[$id]->code = $http_request_fwrite_fail;
+            $responses[$id]->code = HTTPRL_REQUEST_FWRITE_FAIL;
             $responses[$id]->status = 'Done.';
             $responses[$id]->options['timeout'] = $responses[$id]->options['timeout'] - $current_time;
             $stream_write_count--;
@@ -705,7 +726,7 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
       foreach ($streams as $id => $fp) {
         // stream_select timed out & the request is not done.
         $responses[$id]->error = 'stream_select timed out';
-        $responses[$id]->code = HTTP_STREAM_SELECT_TIMEOUT;
+        $responses[$id]->code = HTTPRL_STREAM_SELECT_TIMEOUT;
         $responses[$id]->status = 'Done.';
         $responses[$id]->options['timeout'] = $responses[$id]->options['timeout'] - $current_time;
         fclose($fp);
@@ -731,7 +752,7 @@ function httprl_send_request($fp = NULL, $url = '', $request = '', $options = ''
       'url' => $result->url,
     );
     // Make sure the redirect was requested before killing this request.
-    if ($result->code != $http_request_allowed_redirects_exhausted) {
+    if ($result->code != HTTPRL_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED) {
       unset($responses[$id]);
     }
   }
@@ -844,14 +865,6 @@ function httprl_parse_data(&$result) {
   unset($protocol_code_array);
 
   $result->headers = array();
-  // HTTP_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED is defined in
-  // http://drupal.org/node/1096890
-  if (defined('HTTP_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED')) {
-    $http_request_allowed_redirects_exhausted = HTTP_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED;
-  }
-  else {
-    $http_request_allowed_redirects_exhausted = 2;
-  }
 
   // Parse the response headers.
   $cookie_primary_counter = 0;
@@ -970,7 +983,7 @@ function httprl_parse_data(&$result) {
 
       // Error out if we hit the max redirect.
       if ($result->options['max_redirects'] <= 0) {
-        $result->code = $http_request_allowed_redirects_exhausted;
+        $result->code = HTTPRL_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED;
         $result->error = 'maximum allowed redirects exhausted';
       }
       else {
