diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index af510b8..3b35c93 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -133,15 +133,15 @@
     };
 
     /**
-     * Create an empty key with no attributes.
      * This constructor is being used only for key in mini popup keyboard.
      */
-    public Key(Resources res, Row row, CharSequence popupCharacter, int x, int y) {
-        mKeyboard = row.getKeyboard();
-        mHeight = row.mDefaultHeight - row.mVerticalGap;
-        mGap = row.mDefaultHorizontalGap;
-        mWidth = row.mDefaultWidth - mGap;
-        mEdgeFlags = row.mRowEdgeFlags;
+    public Key(Resources res, Keyboard keyboard, CharSequence popupCharacter, int x, int y,
+            int edgeFlags) {
+        mKeyboard = keyboard;
+        mHeight = keyboard.getRowHeight() - keyboard.getVerticalGap();
+        mGap = keyboard.getHorizontalGap();
+        mWidth = keyboard.getKeyWidth() - mGap;
+        mEdgeFlags = edgeFlags;
         mHintIcon = null;
         mManualTemporaryUpperCaseHintIcon = null;
         mManualTemporaryUpperCaseCode = Keyboard.CODE_DUMMY;
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboardBuilder.java
index 1eb0c3f..33d1960 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboardBuilder.java
@@ -29,13 +29,13 @@
     private final int mNumRows;
     private int mColPos;
     private int mRowPos;
-    private Row mRow;
     private int mX;
     private int mY;
 
     public MiniKeyboardBuilder(Context context, int layoutTemplateResId, Key popupKey) {
         mRes = context.getResources();
-        mKeyboard = new Keyboard(context, layoutTemplateResId, null);
+        final Keyboard keyboard = new Keyboard(context, layoutTemplateResId, null);
+        mKeyboard = keyboard;
         mPopupCharacters = popupKey.mPopupCharacters;
         final int numKeys = mPopupCharacters.length;
         final int maxColumns = popupKey.mMaxPopupColumn;
@@ -43,27 +43,28 @@
         if (numKeys % maxColumns != 0) numRows++;
         mMaxColumns = maxColumns;
         mNumRows = numRows;
+        keyboard.setHeight((keyboard.getRowHeight() + keyboard.getVerticalGap()) * numRows
+                - keyboard.getVerticalGap());
         // TODO: To determine key width we should pay attention to key label length.
-        mRow = new Row(mKeyboard, getRowFlags());
         if (numRows > 1) {
             mColPos = numKeys % maxColumns;
             if (mColPos > 0) mColPos = maxColumns - mColPos;
             // Centering top-row keys.
-            mX = mColPos * (mRow.mDefaultWidth + mRow.mDefaultHorizontalGap) / 2;
+            mX = mColPos * (keyboard.getKeyWidth() + keyboard.getHorizontalGap()) / 2;
         }
         mKeyboard.setMinWidth(0);
     }
 
     public Keyboard build() {
-        List<Key> keys = mKeyboard.getKeys();
+        final Keyboard keyboard = mKeyboard;
+        final List<Key> keys = keyboard.getKeys();
         for (CharSequence label : mPopupCharacters) {
             refresh();
-            final Key key = new Key(mRes, mRow, label, mX, mY);
+            final Key key = new Key(mRes, keyboard, label, mX, mY, getRowFlags());
             keys.add(key);
             advance();
         }
-        finish();
-        return mKeyboard;
+        return keyboard;
     }
 
     private int getRowFlags() {
@@ -76,29 +77,21 @@
 
     private void refresh() {
         if (mColPos >= mMaxColumns) {
-            final Row row = mRow;
+            final Keyboard keyboard = mKeyboard;
             // TODO: Allocate key position depending the precedence of popup characters.
             mX = 0;
-            mY += row.mDefaultHeight + row.mVerticalGap;
+            mY += keyboard.getRowHeight() + keyboard.getVerticalGap();
             mColPos = 0;
-            // TODO: To determine key width we should pay attention to key label length from
-            // bottom to up for rows.
-            mRow = new Row(mKeyboard, getRowFlags());
             mRowPos++;
         }
     }
 
     private void advance() {
-        final Row row = mRow;
         final Keyboard keyboard = mKeyboard;
         // TODO: Allocate key position depending the precedence of popup characters.
-        mX += row.mDefaultWidth + row.mDefaultHorizontalGap;
+        mX += keyboard.getKeyWidth() + keyboard.getHorizontalGap();
         if (mX > keyboard.getMinWidth())
             keyboard.setMinWidth(mX);
         mColPos++;
     }
-
-    private void finish() {
-        mKeyboard.setHeight(mY + mRow.mDefaultHeight);
-    }
-}
\ No newline at end of file
+}
diff --git a/java/src/com/android/inputmethod/keyboard/Row.java b/java/src/com/android/inputmethod/keyboard/Row.java
index 198f02c..3618c04 100644
--- a/java/src/com/android/inputmethod/keyboard/Row.java
+++ b/java/src/com/android/inputmethod/keyboard/Row.java
@@ -45,15 +45,6 @@
 
     private final Keyboard mKeyboard;
 
-    public Row(Keyboard keyboard, int rowFlags) {
-        this.mKeyboard = keyboard;
-        mDefaultHeight = keyboard.getRowHeight();
-        mDefaultWidth = keyboard.getKeyWidth();
-        mDefaultHorizontalGap = keyboard.getHorizontalGap();
-        mVerticalGap = keyboard.getVerticalGap();
-        mRowEdgeFlags = rowFlags;
-    }
-
     public Row(Resources res, Keyboard keyboard, XmlResourceParser parser) {
         this.mKeyboard = keyboard;
         final int keyboardWidth = keyboard.getDisplayWidth();
