diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 60b1184..00368e4 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -77,7 +77,6 @@
 import com.android.settings.dashboard.DashboardCategory;
 import com.android.settings.dashboard.DashboardSummary;
 import com.android.settings.dashboard.DashboardTile;
-import com.android.settings.dashboard.Header;
 import com.android.settings.dashboard.NoHomeDialogFragment;
 import com.android.settings.dashboard.SearchResultsSummary;
 import com.android.settings.deviceinfo.Memory;
@@ -115,7 +114,7 @@
 import java.util.Comparator;
 import java.util.List;
 
-import static com.android.settings.dashboard.Header.HEADER_ID_UNDEFINED;
+import static com.android.settings.dashboard.DashboardTile.TILE_ID_UNDEFINED;
 
 public class SettingsActivity extends Activity
         implements PreferenceManager.OnPreferenceTreeClickListener,
@@ -492,7 +491,7 @@
                 switchToFragment( initialFragmentName, initialArguments, true, false,
                         mInitialTitle, false);
             } else {
-                // No UP if we are displaying the Headers
+                // No UP if we are displaying the main Dashboard
                 mDisplayHomeAsUpEnabled = false;
                 if (mCategories.size() > 0) {
                     mInitialTitle = getText(R.string.dashboard_title);
@@ -672,25 +671,6 @@
     }
 
     /**
-     * When in two-pane mode, switch to the fragment pane to show the given
-     * preference fragment.
-     *
-     * @param header The new header to display.
-     * @param position The position of the Header in the list.
-     */
-    private void onHeaderClick(Header header, int position) {
-        if (header == null) {
-            return;
-        }
-        if (header.fragment != null) {
-            Utils.startWithFragment(this, header.fragment, header.fragmentArguments, null, 0,
-                    header.getTitle(getResources()));
-        } else if (header.intent != null) {
-            startActivity(header.intent);
-        }
-    }
-
-    /**
      * Called to determine whether the header list should be hidden.
      * The default implementation returns the
      * value given in {@link #EXTRA_NO_HEADERS} or false if it is not supplied.
@@ -919,7 +899,7 @@
                                     attrs, com.android.internal.R.styleable.PreferenceHeader);
                             tile.id = sa.getResourceId(
                                     com.android.internal.R.styleable.PreferenceHeader_id,
-                                    (int)HEADER_ID_UNDEFINED);
+                                    (int)TILE_ID_UNDEFINED);
                             tv = sa.peekValue(
                                     com.android.internal.R.styleable.PreferenceHeader_title);
                             if (tv != null && tv.type == TypedValue.TYPE_STRING) {
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index e3335b8..f91a986 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -58,7 +58,6 @@
 import android.widget.TabWidget;
 import com.android.settings.dashboard.DashboardCategory;
 import com.android.settings.dashboard.DashboardTile;
-import com.android.settings.dashboard.Header;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -152,154 +151,6 @@
         return false;
     }
 
-    /**
-     * Finds a matching activity for a preference's intent. If a matching
-     * activity is not found, it will remove the preference. The icon, title and
-     * summary of the preference will also be updated with the values retrieved
-     * from the activity's meta-data elements. If no meta-data elements are
-     * specified then the preference title will be set to match the label of the
-     * activity, an icon and summary text will not be displayed.
-     *
-     * @param context The context.
-     * @param parentPreferenceGroup The preference group that contains the
-     *            preference whose intent is being resolved.
-     * @param preferenceKey The key of the preference whose intent is being
-     *            resolved.
-     *
-     * @return Whether an activity was found. If false, the preference was
-     *         removed.
-     *
-     * @see {@link #META_DATA_PREFERENCE_ICON}
-     *      {@link #META_DATA_PREFERENCE_TITLE}
-     *      {@link #META_DATA_PREFERENCE_SUMMARY}
-     */
-    public static boolean updatePreferenceToSpecificActivityFromMetaDataOrRemove(Context context,
-            PreferenceGroup parentPreferenceGroup, String preferenceKey) {
-
-        IconPreferenceScreen preference = (IconPreferenceScreen)parentPreferenceGroup
-                .findPreference(preferenceKey);
-        if (preference == null) {
-            return false;
-        }
-
-        Intent intent = preference.getIntent();
-        if (intent != null) {
-            // Find the activity that is in the system image
-            PackageManager pm = context.getPackageManager();
-            List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
-            int listSize = list.size();
-            for (int i = 0; i < listSize; i++) {
-                ResolveInfo resolveInfo = list.get(i);
-                if ((resolveInfo.activityInfo.applicationInfo.flags
-                        & ApplicationInfo.FLAG_SYSTEM) != 0) {
-                    Drawable icon = null;
-                    String title = null;
-                    String summary = null;
-
-                    // Get the activity's meta-data
-                    try {
-                        Resources res = pm
-                                .getResourcesForApplication(resolveInfo.activityInfo.packageName);
-                        Bundle metaData = resolveInfo.activityInfo.metaData;
-
-                        if (res != null && metaData != null) {
-                            icon = res.getDrawable(metaData.getInt(META_DATA_PREFERENCE_ICON));
-                            title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
-                            summary = res.getString(metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
-                        }
-                    } catch (NameNotFoundException e) {
-                        // Ignore
-                    } catch (NotFoundException e) {
-                        // Ignore
-                    }
-
-                    // Set the preference title to the activity's label if no
-                    // meta-data is found
-                    if (TextUtils.isEmpty(title)) {
-                        title = resolveInfo.loadLabel(pm).toString();
-                    }
-
-                    // Set icon, title and summary for the preference
-                    preference.setIcon(icon);
-                    preference.setTitle(title);
-                    preference.setSummary(summary);
-
-                    // Replace the intent with this specific activity
-                    preference.setIntent(new Intent().setClassName(
-                            resolveInfo.activityInfo.packageName,
-                            resolveInfo.activityInfo.name));
-
-                   return true;
-                }
-            }
-        }
-
-        // Did not find a matching activity, so remove the preference
-        parentPreferenceGroup.removePreference(preference);
-
-        return false;
-    }
-
-    public static boolean updateHeaderToSpecificActivityFromMetaDataOrRemove(Context context,
-            List<Header> target, Header header) {
-
-        Intent intent = header.intent;
-        if (intent != null) {
-            // Find the activity that is in the system image
-            PackageManager pm = context.getPackageManager();
-            List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
-            int listSize = list.size();
-            for (int i = 0; i < listSize; i++) {
-                ResolveInfo resolveInfo = list.get(i);
-                if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
-                        != 0) {
-                    Drawable icon = null;
-                    String title = null;
-                    String summary = null;
-
-                    // Get the activity's meta-data
-                    try {
-                        Resources res = pm.getResourcesForApplication(
-                                resolveInfo.activityInfo.packageName);
-                        Bundle metaData = resolveInfo.activityInfo.metaData;
-
-                        if (res != null && metaData != null) {
-                            icon = res.getDrawable(metaData.getInt(META_DATA_PREFERENCE_ICON));
-                            title = res.getString(metaData.getInt(META_DATA_PREFERENCE_TITLE));
-                            summary = res.getString(metaData.getInt(META_DATA_PREFERENCE_SUMMARY));
-                        }
-                    } catch (NameNotFoundException e) {
-                        // Ignore
-                    } catch (NotFoundException e) {
-                        // Ignore
-                    }
-
-                    // Set the preference title to the activity's label if no
-                    // meta-data is found
-                    if (TextUtils.isEmpty(title)) {
-                        title = resolveInfo.loadLabel(pm).toString();
-                    }
-
-                    // Set icon, title and summary for the preference
-                    // TODO:
-                    //header.icon = icon;
-                    header.title = title;
-                    header.summary = summary;
-                    // Replace the intent with this specific activity
-                    header.intent = new Intent().setClassName(resolveInfo.activityInfo.packageName,
-                            resolveInfo.activityInfo.name);
-
-                    return true;
-                }
-            }
-        }
-
-        // Did not find a matching activity, so remove the preference
-        target.remove(header);
-
-        return false;
-    }
-
     public static boolean updateTileToSpecificActivityFromMetaDataOrRemove(Context context,
             DashboardCategory target, DashboardTile tile) {
 
diff --git a/src/com/android/settings/dashboard/Header.java b/src/com/android/settings/dashboard/Header.java
deleted file mode 100644
index 86e55ac..0000000
--- a/src/com/android/settings/dashboard/Header.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.dashboard;
-
-import android.content.Intent;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.text.TextUtils;
-
-/**
- * Description of a single Header item that the user can select.
- */
-public class Header implements Parcelable {
-    /**
-     * Default value for {@link Header#id Header.id} indicating that no
-     * identifier value is set.  All other values (including those below -1)
-     * are valid.
-     */
-    public static final long HEADER_ID_UNDEFINED = -1;
-
-    /**
-     * Identifier for this header, to correlate with a new list when
-     * it is updated.  The default value is
-     * {@link Header#HEADER_ID_UNDEFINED}, meaning no id.
-     * @attr ref android.R.styleable#PreferenceHeader_id
-     */
-    public long id = HEADER_ID_UNDEFINED;
-
-    /**
-     * Resource ID of title of the header that is shown to the user.
-     * @attr ref android.R.styleable#PreferenceHeader_title
-     */
-    public int titleRes;
-
-    /**
-     * Title of the header that is shown to the user.
-     * @attr ref android.R.styleable#PreferenceHeader_title
-     */
-    public CharSequence title;
-
-    /**
-     * Resource ID of optional summary describing what this header controls.
-     * @attr ref android.R.styleable#PreferenceHeader_summary
-     */
-    public int summaryRes;
-
-    /**
-     * Optional summary describing what this header controls.
-     * @attr ref android.R.styleable#PreferenceHeader_summary
-     */
-    public CharSequence summary;
-
-    /**
-     * Optional icon resource to show for this header.
-     * @attr ref android.R.styleable#PreferenceHeader_icon
-     */
-    public int iconRes;
-
-    /**
-     * Full class name of the fragment to display when this header is
-     * selected.
-     * @attr ref android.R.styleable#PreferenceHeader_fragment
-     */
-    public String fragment;
-
-    /**
-     * Optional arguments to supply to the fragment when it is
-     * instantiated.
-     */
-    public Bundle fragmentArguments;
-
-    /**
-     * Intent to launch when the preference is selected.
-     */
-    public Intent intent;
-
-    /**
-     * Optional additional data for use by subclasses of the activity
-     */
-    public Bundle extras;
-
-    public Header() {
-        // Empty
-    }
-
-    /**
-     * Return the currently set title.  If {@link #titleRes} is set,
-     * this resource is loaded from <var>res</var> and returned.  Otherwise
-     * {@link #title} is returned.
-     */
-    public CharSequence getTitle(Resources res) {
-        if (titleRes != 0) {
-            return res.getText(titleRes);
-        }
-        return title;
-    }
-
-    /**
-     * Return the currently set summary.  If {@link #summaryRes} is set,
-     * this resource is loaded from <var>res</var> and returned.  Otherwise
-     * {@link #summary} is returned.
-     */
-    public CharSequence getSummary(Resources res) {
-        if (summaryRes != 0) {
-            return res.getText(summaryRes);
-        }
-        return summary;
-    }
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeLong(id);
-        dest.writeInt(titleRes);
-        TextUtils.writeToParcel(title, dest, flags);
-        dest.writeInt(summaryRes);
-        TextUtils.writeToParcel(summary, dest, flags);
-        dest.writeInt(iconRes);
-        dest.writeString(fragment);
-        dest.writeBundle(fragmentArguments);
-        if (intent != null) {
-            dest.writeInt(1);
-            intent.writeToParcel(dest, flags);
-        } else {
-            dest.writeInt(0);
-        }
-        dest.writeBundle(extras);
-    }
-
-    public void readFromParcel(Parcel in) {
-        id = in.readLong();
-        titleRes = in.readInt();
-        title = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
-        summaryRes = in.readInt();
-        summary = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
-        iconRes = in.readInt();
-        fragment = in.readString();
-        fragmentArguments = in.readBundle();
-        if (in.readInt() != 0) {
-            intent = Intent.CREATOR.createFromParcel(in);
-        }
-        extras = in.readBundle();
-    }
-
-    Header(Parcel in) {
-        readFromParcel(in);
-    }
-
-    public static final Creator<Header> CREATOR = new Creator<Header>() {
-        public Header createFromParcel(Parcel source) {
-            return new Header(source);
-        }
-        public Header[] newArray(int size) {
-            return new Header[size];
-        }
-    };
-}
