diff --git a/includes/common.inc b/includes/common.inc
index 5dddd790c363c9b14d99ddbffa60ad7f82f58e7c..f4cbac5948e9b18c65b886f97167f70e1ff48227 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -185,6 +185,10 @@ function drupal_get_path_alias($path) {
   elseif (function_exists("conf_url_rewrite")) {
     return conf_url_rewrite($path, 'outgoing');
   }
+  else {
+    // No alias found. Return the normal path.
+    return $path;
+  }
 }
 
 /**
@@ -1171,9 +1175,7 @@ function url($url = NULL, $query = NULL, $fragment = NULL, $absolute = NULL) {
     $script = (strpos($_SERVER["SERVER_SOFTWARE"], "Apache") === false) ? "index.php" : "";
   }
 
-  if ($alias = drupal_get_path_alias($url)) {
-    $url = $alias;
-  }
+  $url = drupal_get_path_alias($url);
 
   if (isset($fragment)) {
     $fragment = "#$fragment";
diff --git a/includes/menu.inc b/includes/menu.inc
index 0e208786be20c93d99dec0dc222f828f4c5a9a75..49f13a06c55c6cecc222365f79d2c06e9bb5b6cf 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -176,7 +176,7 @@ function menu_get_active_breadcrumb() {
 
   $links[] = l(t('Home'), '');
 
-  $trail = menu_get_trail($_GET['q']);
+  $trail = menu_get_trail(drupal_get_path_alias($_GET['q']));
 
   // The last item in the trail is the page title; don't display it here.
   array_pop($trail);
@@ -249,7 +249,7 @@ function menu_in_active_trail($mid) {
   static $trail;
 
   if (empty($trail)) {
-    $trail = menu_get_trail($_GET['q']);
+    $trail = menu_get_trail(drupal_get_path_alias($_GET['q']));
   }
 
   return in_array($mid, $trail);
diff --git a/modules/path.module b/modules/path.module
index 5ac3cc9823aca63e0c753dac2f02c2e393e69750..d72c56690050f8e3b10c0bee19077c4e0a982232 100644
--- a/modules/path.module
+++ b/modules/path.module
@@ -175,7 +175,11 @@ function path_nodeapi(&$node, $op, $arg) {
         // viewing of the form.  If it is the first time, load the alias, if it isn't
         // (i.e., user has clicked preview) let them work with their current form alias.
         if (is_null($node->path)) {
-          $node->path = drupal_get_path_alias("node/view/$node->nid");
+          $path = "node/view/$node->nid";
+          $alias = drupal_get_path_alias($path);
+          if ($alias != $path) {
+            $node->path = $alias;
+          }
         }
         else {
           $node->path = trim($node->path);
@@ -205,8 +209,9 @@ function path_nodeapi(&$node, $op, $arg) {
         break;
 
       case 'delete':
-        if ($alias = drupal_get_path_alias("node/view/$node->nid")) {
-          path_set_alias("node/view/$node->nid");
+        $path = "node/view/$node->nid";
+        if (drupal_get_path_alias($path) != $path) {
+          path_set_alias($path);
         }
         break;
     }
diff --git a/modules/path/path.module b/modules/path/path.module
index 5ac3cc9823aca63e0c753dac2f02c2e393e69750..d72c56690050f8e3b10c0bee19077c4e0a982232 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -175,7 +175,11 @@ function path_nodeapi(&$node, $op, $arg) {
         // viewing of the form.  If it is the first time, load the alias, if it isn't
         // (i.e., user has clicked preview) let them work with their current form alias.
         if (is_null($node->path)) {
-          $node->path = drupal_get_path_alias("node/view/$node->nid");
+          $path = "node/view/$node->nid";
+          $alias = drupal_get_path_alias($path);
+          if ($alias != $path) {
+            $node->path = $alias;
+          }
         }
         else {
           $node->path = trim($node->path);
@@ -205,8 +209,9 @@ function path_nodeapi(&$node, $op, $arg) {
         break;
 
       case 'delete':
-        if ($alias = drupal_get_path_alias("node/view/$node->nid")) {
-          path_set_alias("node/view/$node->nid");
+        $path = "node/view/$node->nid";
+        if (drupal_get_path_alias($path) != $path) {
+          path_set_alias($path);
         }
         break;
     }
diff --git a/modules/profile.module b/modules/profile.module
index eef0f93a2e547aa3a7f0373724825563a05c2c8b..9663342d3e57c68150425f274f5fcbe5e0f8c0dc 100644
--- a/modules/profile.module
+++ b/modules/profile.module
@@ -30,11 +30,13 @@ function profile_link($type) {
 
 function profile_browse() {
 
+  $name = strip_tags(arg(1));
+  $value = strip_tags(arg(2));
 
-  $field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page FROM {profile_fields} WHERE name = '%s'", arg(1)));
+  $field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page FROM {profile_fields} WHERE name = '%s'", $name));
 
   if ($field->fid) {
-    // Compile a list of fields to show:
+    // Compile a list of fields to show
     $fields = array();
     $result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid);
     while ($record = db_fetch_object($result)) {
@@ -47,10 +49,10 @@ function profile_browse() {
         $query = 'v.value = 1';
         break;
       case 'selection':
-        $query = "v.value = '". check_query(arg(2)) ."'";
+        $query = "v.value = '". check_query($value) ."'";
         break;
       case 'list':
-        $query = "v.value LIKE '%". check_query(arg(2)) ."%'";
+        $query = "v.value LIKE '%". check_query($value) ."%'";
         break;
     }
 
@@ -64,7 +66,7 @@ function profile_browse() {
     $output .= theme('pager', NULL, 20);
 
     if ($field->type == 'selection' || $field->type == 'list') {
-      $title = strtr($field->page, array('%value' => arg(2)));
+      $title = strtr($field->page, array('%value' => $value));
     }
     else {
       $title = $field->page;
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index eef0f93a2e547aa3a7f0373724825563a05c2c8b..9663342d3e57c68150425f274f5fcbe5e0f8c0dc 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -30,11 +30,13 @@ function profile_link($type) {
 
 function profile_browse() {
 
+  $name = strip_tags(arg(1));
+  $value = strip_tags(arg(2));
 
-  $field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page FROM {profile_fields} WHERE name = '%s'", arg(1)));
+  $field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page FROM {profile_fields} WHERE name = '%s'", $name));
 
   if ($field->fid) {
-    // Compile a list of fields to show:
+    // Compile a list of fields to show
     $fields = array();
     $result = db_query("SELECT name, title, type FROM {profile_fields} WHERE fid != %d AND overview = 1", $field->fid);
     while ($record = db_fetch_object($result)) {
@@ -47,10 +49,10 @@ function profile_browse() {
         $query = 'v.value = 1';
         break;
       case 'selection':
-        $query = "v.value = '". check_query(arg(2)) ."'";
+        $query = "v.value = '". check_query($value) ."'";
         break;
       case 'list':
-        $query = "v.value LIKE '%". check_query(arg(2)) ."%'";
+        $query = "v.value LIKE '%". check_query($value) ."%'";
         break;
     }
 
@@ -64,7 +66,7 @@ function profile_browse() {
     $output .= theme('pager', NULL, 20);
 
     if ($field->type == 'selection' || $field->type == 'list') {
-      $title = strtr($field->page, array('%value' => arg(2)));
+      $title = strtr($field->page, array('%value' => $value));
     }
     else {
       $title = $field->page;
diff --git a/modules/user.module b/modules/user.module
index f28a5ee997ea384ae34c25b1e9534c2971539e9e..1d5551eec969608e97ae833fc1c69665b931b943 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -903,18 +903,18 @@ function user_register($edit = array()) {
         }
       }
     }
-      
+
     if (!form_has_errors()) {
       $from = variable_get('site_mail', ini_get('sendmail_from'));
       $pass = user_password();
-  
+
       // TODO: Is this necessary? Won't session_write() replicate this?
       unset($edit['session']);
       $account = user_save('', array_merge(array('name' => $edit['name'], 'pass' => $pass, 'init' => $edit['mail'], 'mail' => $edit['mail'], 'rid' => array(_user_authenticated_id()), 'status' => (variable_get('user_register', 1) == 1 ? 1 : 0)), $data));
       watchdog('user', 'new user: "'. $edit['name'] .'" <'. $edit['mail'] .'>', l(t('edit user'), "admin/user/edit/$account->uid"));
-  
+
       $variables = array('%username' => $edit['name'], '%site' => variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $edit['mail'], '%date' => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE), '%edit_uri' => url('user/edit', NULL, NULL, TRUE));
-  
+
       // The first user may login immediately, and receives a customized welcome e-mail.
       if ($account->uid == 1) {
         user_mail($edit['mail'], t('drupal user account details for %s', array('%s' => $edit['name'])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n  username: %username\n  password: %password\n\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
diff --git a/modules/user/user.module b/modules/user/user.module
index f28a5ee997ea384ae34c25b1e9534c2971539e9e..1d5551eec969608e97ae833fc1c69665b931b943 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -903,18 +903,18 @@ function user_register($edit = array()) {
         }
       }
     }
-      
+
     if (!form_has_errors()) {
       $from = variable_get('site_mail', ini_get('sendmail_from'));
       $pass = user_password();
-  
+
       // TODO: Is this necessary? Won't session_write() replicate this?
       unset($edit['session']);
       $account = user_save('', array_merge(array('name' => $edit['name'], 'pass' => $pass, 'init' => $edit['mail'], 'mail' => $edit['mail'], 'rid' => array(_user_authenticated_id()), 'status' => (variable_get('user_register', 1) == 1 ? 1 : 0)), $data));
       watchdog('user', 'new user: "'. $edit['name'] .'" <'. $edit['mail'] .'>', l(t('edit user'), "admin/user/edit/$account->uid"));
-  
+
       $variables = array('%username' => $edit['name'], '%site' => variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mailto' => $edit['mail'], '%date' => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE), '%edit_uri' => url('user/edit', NULL, NULL, TRUE));
-  
+
       // The first user may login immediately, and receives a customized welcome e-mail.
       if ($account->uid == 1) {
         user_mail($edit['mail'], t('drupal user account details for %s', array('%s' => $edit['name'])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n  username: %username\n  password: %password\n\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");