diff --git a/includes/file.inc b/includes/file.inc
index 1e256c6..db683cc 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -1978,10 +1978,10 @@ function file_download() {
     if (count($headers)) {
       file_transfer($uri, $headers);
     }
-    drupal_access_denied();
+    return MENU_ACCESS_DENIED;
   }
   else {
-    drupal_not_found();
+    return MENU_NOT_FOUND;
   }
   drupal_exit();
 }
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 4241538..9fc274e 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -490,7 +490,7 @@ function comment_permalink($cid) {
     // Return the node view, this will show the correct comment in context.
     return menu_execute_active_handler('node/' . $node->nid, FALSE);
   }
-  drupal_not_found();
+  return MENU_NOT_FOUND;
 }
 
 /**
diff --git a/modules/image/image.module b/modules/image/image.module
index ff50452..8bad8a7 100644
--- a/modules/image/image.module
+++ b/modules/image/image.module
@@ -782,12 +782,12 @@ function image_style_deliver($style, $scheme) {
   // control access to the file.
   if ($scheme == 'private') {
     if (file_exists($derivative_uri)) {
-      file_download($scheme, file_uri_target($derivative_uri));
+      return file_download($scheme, file_uri_target($derivative_uri));
     }
     else {
       $headers = module_invoke_all('file_download', $image_uri);
       if (in_array(-1, $headers) || empty($headers)) {
-        return drupal_access_denied();
+        return MENU_ACCESS_DENIED;
       }
       if (count($headers)) {
         foreach ($headers as $name => $value) {
diff --git a/modules/profile/profile.admin.inc b/modules/profile/profile.admin.inc
index d6ac3c3..5e2109d 100644
--- a/modules/profile/profile.admin.inc
+++ b/modules/profile/profile.admin.inc
@@ -192,8 +192,7 @@ function profile_field_form($form, &$form_state, $arg = NULL) {
       $edit = db_query('SELECT * FROM {profile_field} WHERE fid = :fid', array('fid' => $fid))->fetchAssoc();
 
       if (!$edit) {
-        drupal_not_found();
-        return;
+        return MENU_NOT_FOUND;
       }
       drupal_set_title(t('Edit %title', array('%title' => $edit['title'])), PASS_THROUGH);
       $form['fid'] = array('#type' => 'value',
@@ -202,15 +201,13 @@ function profile_field_form($form, &$form_state, $arg = NULL) {
       $type = $edit['type'];
     }
     else {
-      drupal_not_found();
-      return;
+      return MENU_NOT_FOUND;
     }
   }
   else {
     $types = _profile_field_types();
     if (!isset($types[$arg])) {
-      drupal_not_found();
-      return;
+      return MENU_NOT_FOUND;
     }
     $type = $arg;
     drupal_set_title(t('Add new %type', array('%type' => $types[$type])), PASS_THROUGH);
@@ -396,8 +393,7 @@ function profile_field_form_submit($form, &$form_state) {
 function profile_field_delete($form, &$form_state, $fid) {
   $field = db_query("SELECT title FROM {profile_field} WHERE fid = :fid", array(':fid' => $fid))->fetchObject();
   if (!$field) {
-    drupal_not_found();
-    return;
+    return MENU_NOT_FOUND;
   }
   $form['fid'] = array('#type' => 'value', '#value' => $fid);
   $form['title'] = array('#type' => 'value', '#value' => $field->title);
diff --git a/modules/profile/profile.pages.inc b/modules/profile/profile.pages.inc
index 06f9632..2d6647a 100644
--- a/modules/profile/profile.pages.inc
+++ b/modules/profile/profile.pages.inc
@@ -17,13 +17,11 @@ function profile_browse() {
   if ($name && $field->fid) {
     // Only allow browsing of fields that have a page title set.
     if (empty($field->page)) {
-      drupal_not_found();
-      return;
+      return MENU_NOT_FOUND;
     }
     // Do not allow browsing of private and hidden fields by non-admins.
     if (!user_access('administer users') && ($field->visibility == PROFILE_PRIVATE || $field->visibility == PROFILE_HIDDEN)) {
-      drupal_access_denied();
-      return;
+      return MENU_ACCESS_DENIED;
     }
 
     // Compile a list of fields to show.
@@ -54,8 +52,7 @@ function profile_browse() {
         $query->condition('v.value', '%' . db_like($value) . '%', 'LIKE');
         break;
       default:
-        drupal_not_found();
-        return;
+        return MENU_NOT_FOUND;
     }
 
     $uids = $query
@@ -85,7 +82,7 @@ function profile_browse() {
     return $output;
   }
   elseif ($name && !$field->fid) {
-    drupal_not_found();
+    return MENU_NOT_FOUND;
   }
   else {
     // Compile a list of fields to show.
diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test
index 3df31ba..d70bff3 100644
--- a/modules/simpletest/tests/file.test
+++ b/modules/simpletest/tests/file.test
@@ -2396,10 +2396,24 @@ class FileDownloadTest extends FileTestCase {
     $this->drupalHead($url);
     $this->assertResponse(403, t('Correctly denied access to a file when file_test sets the header to -1.'));
 
+    // Test that 403 page is cached and gzip compressed.
+    variable_set('cache', 1);
+    $this->drupalGet($url, array(), array('Accept-Encoding: gzip,deflate'));
+    $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8)));
+    $this->assertRaw('</html>', t('Page was gzip compressed.'));
+    variable_set('cache', 0);
+
     // Try non-existent file.
     $url = file_create_url('private://' . $this->randomName());
     $this->drupalHead($url);
     $this->assertResponse(404, t('Correctly returned 404 response for a non-existent file.'));
+
+    // Test that 404 page is cached and gzip compressed.
+    variable_set('cache', 1);
+    $this->drupalGet($url, array(), array('Accept-Encoding: gzip,deflate'));
+    $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8)));
+    $this->assertRaw('</html>', t('Page was gzip compressed.'));
+    variable_set('cache', 0);
   }
 
   /**
