diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index f189cd5..56d6a99 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -280,33 +280,6 @@
         return  widthGap * (numCells - 1) + cellWidth * numCells + crosshairsSize;
     }
 
-    static int widthInLandscape(Resources r, int numCells) {
-        // We use this method from Workspace to figure out how many rows/columns Launcher should
-        // have. We ignore the left/right padding on CellLayout because it turns out in our design
-        // the padding extends outside the visible screen size, but it looked fine anyway.
-        // However, we make sure there's at least enough space for the crosshairs at either
-        // edge to be rendered (half the crosshair is sticking out on either side)
-        int cellWidth = r.getDimensionPixelSize(R.dimen.workspace_cell_width);
-        int widthGap = r.getDimensionPixelSize(R.dimen.workspace_width_gap_land);
-        int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicWidth();
-
-        return widthGap * (numCells - 1) + cellWidth * numCells + crosshairsSize;
-    }
-
-    static int heightInPortrait(Resources r, int numCells) {
-        // We use this method from Workspace to figure out how many rows/columns Launcher should
-        // have. We ignore the left/right padding on CellLayout because it turns out in our design
-        // the padding extends outside the visible screen size, but it looked fine anyway.
-        // However, we make sure there's at least enough space for the crosshairs at the bottom
-        // to be rendered (half the crosshair is sticking out); we don't worry about the top
-        // crosshair since it can bleed into the action bar space
-        int cellHeight = r.getDimensionPixelSize(R.dimen.workspace_cell_height);
-        int heightGap = r.getDimensionPixelSize(R.dimen.workspace_height_gap_port);
-        int crosshairsSize = r.getDrawable(R.drawable.gardening_crosshairs).getIntrinsicHeight();
-
-        return heightGap * (numCells - 1) + cellHeight * numCells + (crosshairsSize + 1) / 2;
-    }
-
     static int heightInLandscape(Resources r, int numCells) {
         // We use this method from Workspace to figure out how many rows/columns Launcher should
         // have. We ignore the left/right padding on CellLayout because it turns out in our design
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 7d1ee19..e0472fc 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -52,7 +52,6 @@
 import android.os.IBinder;
 import android.os.Parcelable;
 import android.util.AttributeSet;
-import android.util.DisplayMetrics;
 import android.util.Log;
 import android.util.Pair;
 import android.view.Display;
@@ -272,42 +271,28 @@
                 R.styleable.Workspace, defStyle, 0);
 
         if (LauncherApplication.isScreenLarge()) {
+            // Determine number of rows/columns dynamically
+            // TODO: This code currently fails on tablets with an aspect ratio < 1.3.
+            // Around that ratio we should make cells the same size in portrait and
+            // landscape
             final Resources res = context.getResources();
-            final DisplayMetrics dm = res.getDisplayMetrics();
-            float widthDp = dm.widthPixels / dm.density;
-            float heightDp = dm.heightPixels / dm.density;
 
-            final float statusBarHeight = res.getDimension(R.dimen.status_bar_height);
             TypedArray actionBarSizeTypedArray =
                 context.obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
-            float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f);
+            final float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f);
+            final float systemBarHeight = res.getDimension(R.dimen.status_bar_height);
+            final float smallestScreenDim = res.getConfiguration().smallestScreenWidthDp;
 
-            if (heightDp > widthDp) {
-                float temp = widthDp;
-                widthDp = heightDp;
-                heightDp = temp;
+            cellCountX = 1;
+            while (CellLayout.widthInPortrait(res, cellCountX + 1) <= smallestScreenDim) {
+                cellCountX++;
             }
-            int cellCountXLand = 1;
-            int cellCountXPort = 1;
-            while (2*mPageSpacing + CellLayout.widthInLandscape(res, cellCountXLand + 1) <= widthDp) {
-                cellCountXLand++;
-            }
-            while (CellLayout.widthInPortrait(res, cellCountXPort + 1) <= heightDp) {
-                cellCountXPort++;
-            }
-            cellCountX = Math.min(cellCountXLand, cellCountXPort);
 
-            int cellCountYLand = 1;
-            int cellCountYPort = 1;
-            while (statusBarHeight + actionBarHeight +
-                    CellLayout.heightInLandscape(res, cellCountYLand + 1) <= heightDp) {
-                cellCountYLand++;
+            cellCountY = 1;
+            while (actionBarHeight + CellLayout.heightInLandscape(res, cellCountY + 1)
+                <= smallestScreenDim - systemBarHeight) {
+                cellCountY++;
             }
-            while (statusBarHeight + actionBarHeight +
-                    CellLayout.heightInPortrait(res, cellCountYPort + 1) <= widthDp) {
-                cellCountYPort++;
-            }
-            cellCountY = Math.min(cellCountYLand, cellCountYPort);
         }
 
         // if the value is manually specified, use that instead
