diff --git a/java/res/values-xlarge/dimens.xml b/java/res/values-xlarge/dimens.xml
index 11ad6b1..6928320 100644
--- a/java/res/values-xlarge/dimens.xml
+++ b/java/res/values-xlarge/dimens.xml
@@ -42,7 +42,6 @@
     <dimen name="key_preview_text_size_large">24dip</dimen>
     <!-- left or right padding of label alignment -->
     <dimen name="key_label_horizontal_alignment_padding">6dip</dimen>
-    <dimen name="keyboard_bottom_row_vertical_correction">10.0mm</dimen>
 
     <dimen name="candidate_strip_height">46dip</dimen>
     <dimen name="candidate_strip_padding">15.0mm</dimen>
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index 90bf1bf..7f00cdb 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -46,7 +46,6 @@
     <!-- We use "inch", not "dip" because this value tries dealing with physical distance related
          to user's finger. -->
     <dimen name="keyboard_vertical_correction">-0.05in</dimen>
-    <dimen name="keyboard_bottom_row_vertical_correction">0.0mm</dimen>
 
     <dimen name="candidate_strip_height">42dip</dimen>
     <dimen name="candidate_strip_fading_edge_length">63dip</dimen>
diff --git a/java/src/com/android/inputmethod/latin/ClipTouchEventWindowCallback.java b/java/src/com/android/inputmethod/latin/ClipTouchEventWindowCallback.java
deleted file mode 100644
index d12c700..0000000
--- a/java/src/com/android/inputmethod/latin/ClipTouchEventWindowCallback.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011 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.inputmethod.latin;
-
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.Window;
-
-public class ClipTouchEventWindowCallback extends WindowCallbackAdapter {
-    private final View mDecorView;
-    private final int mKeyboardBottomRowVerticalCorrection;
-
-    public ClipTouchEventWindowCallback(Window window, int keyboardBottomRowVerticalCorrection) {
-        super(window.getCallback());
-        mDecorView = window.getDecorView();
-        mKeyboardBottomRowVerticalCorrection = keyboardBottomRowVerticalCorrection;
-    }
-
-    @Override
-    public boolean dispatchTouchEvent(MotionEvent me) {
-        final int height = mDecorView.getHeight();
-        final MotionEvent event = clipMotionEvent(me, height,
-                height + mKeyboardBottomRowVerticalCorrection);
-        return super.dispatchTouchEvent(event);
-    }
-
-    private static MotionEvent clipMotionEvent(MotionEvent me, int minHeight, int maxHeight) {
-        final int pointerCount = me.getPointerCount();
-        boolean shouldClip = false;
-        for (int pointerIndex = 0; pointerIndex < pointerCount; pointerIndex++) {
-            final float y = me.getY(pointerIndex);
-            if (y >= minHeight && y < maxHeight) {
-                shouldClip = true;
-                break;
-            }
-        }
-        if (!shouldClip)
-            return me;
-
-        if (pointerCount == 1) {
-            me.setLocation(me.getX(), minHeight - 1);
-            return me;
-        }
-
-        final int[] pointerIds = new int[pointerCount];
-        final MotionEvent.PointerCoords[] pointerCoords =
-                new MotionEvent.PointerCoords[pointerCount];
-        for (int pointerIndex = 0; pointerIndex < pointerCount; pointerIndex++) {
-            pointerIds[pointerIndex] = me.getPointerId(pointerIndex);
-            final MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords();
-            me.getPointerCoords(pointerIndex, coords);
-            pointerCoords[pointerIndex] = coords;
-            if (coords.y >= minHeight && coords.y < maxHeight)
-                coords.y = minHeight - 1;
-        }
-        return MotionEvent.obtain(
-                me.getDownTime(), me.getEventTime(), me.getAction(), pointerCount, pointerIds,
-                pointerCoords, me.getMetaState(), me.getXPrecision(), me.getYPrecision(),
-                me.getDeviceId(), me.getEdgeFlags(), me.getSource(), me.getFlags());
-    }
-}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 198d34f..bbe3f78 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -161,8 +161,6 @@
     private int mConfigDelayBeforeFadeoutLanguageOnSpacebar;
     private int mConfigDurationOfFadeoutLanguageOnSpacebar;
     private float mConfigFinalFadeoutFactorOfLanguageOnSpacebar;
-    // For example, to deal with status bar on tablet.
-    private int mKeyboardBottomRowVerticalCorrection;
 
     private int mCorrectionMode;
     private int mCommittedLength;
@@ -379,8 +377,6 @@
                 R.integer.config_duration_of_fadeout_language_on_spacebar);
         mConfigFinalFadeoutFactorOfLanguageOnSpacebar = res.getInteger(
                 R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f;
-        mKeyboardBottomRowVerticalCorrection = (int)res.getDimension(
-                R.dimen.keyboard_bottom_row_vertical_correction);
 
         Utils.GCUtils.getInstance().reset();
         boolean tryGC = true;
@@ -573,14 +569,6 @@
 
         mVoiceConnector.onStartInputView(inputView.getWindowToken());
 
-        if (mKeyboardBottomRowVerticalCorrection > 0) {
-            final Window window = getWindow().getWindow();
-            if (!(window.getCallback() instanceof ClipTouchEventWindowCallback)) {
-                window.setCallback(new ClipTouchEventWindowCallback(
-                        window, mKeyboardBottomRowVerticalCorrection));
-            }
-        }
-
         if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
     }
 
@@ -895,13 +883,15 @@
             if (mCandidateViewContainer != null) {
                 ViewParent candidateParent = mCandidateViewContainer.getParent();
                 if (candidateParent instanceof FrameLayout) {
-                    final FrameLayout fl = (FrameLayout) candidateParent;
-                    // Check frame layout's visibility
-                    if (fl.getVisibility() == View.INVISIBLE) {
-                        y = fl.getHeight();
-                        height += y;
-                    } else if (fl.getVisibility() == View.VISIBLE) {
-                        height += fl.getHeight();
+                    FrameLayout fl = (FrameLayout) candidateParent;
+                    if (fl != null) {
+                        // Check frame layout's visibility
+                        if (fl.getVisibility() == View.INVISIBLE) {
+                            y = fl.getHeight();
+                            height += y;
+                        } else if (fl.getVisibility() == View.VISIBLE) {
+                            height += fl.getHeight();
+                        }
                     }
                 }
             }
diff --git a/java/src/com/android/inputmethod/latin/WindowCallbackAdapter.java b/java/src/com/android/inputmethod/latin/WindowCallbackAdapter.java
deleted file mode 100644
index be9bb2b..0000000
--- a/java/src/com/android/inputmethod/latin/WindowCallbackAdapter.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2011 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.inputmethod.latin;
-
-import android.view.ActionMode;
-import android.view.ActionMode.Callback;
-import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager.LayoutParams;
-import android.view.accessibility.AccessibilityEvent;
-
-public class WindowCallbackAdapter implements Window.Callback {
-    private final Window.Callback mPreviousCallback;
-
-    public WindowCallbackAdapter(Window.Callback previousCallback) {
-        mPreviousCallback = previousCallback;
-    }
-
-    @Override
-    public boolean dispatchKeyEvent(KeyEvent event) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.dispatchKeyEvent(event);
-        return false;
-    }
-
-    @Override
-    public boolean dispatchKeyShortcutEvent(KeyEvent event) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.dispatchKeyShortcutEvent(event);
-        return false;
-    }
-
-    @Override
-    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.dispatchPopulateAccessibilityEvent(event);
-        return false;
-    }
-
-    @Override
-    public boolean dispatchTouchEvent(MotionEvent event) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.dispatchTouchEvent(event);
-        return false;
-    }
-
-    @Override
-    public boolean dispatchTrackballEvent(MotionEvent event) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.dispatchTrackballEvent(event);
-        return false;
-    }
-
-    @Override
-    public void onActionModeFinished(ActionMode mode) {
-        if (mPreviousCallback != null)
-            mPreviousCallback.onActionModeFinished(mode);
-    }
-
-    @Override
-    public void onActionModeStarted(ActionMode mode) {
-        if (mPreviousCallback != null)
-            mPreviousCallback.onActionModeStarted(mode);
-    }
-
-    @Override
-    public void onAttachedToWindow() {
-        if (mPreviousCallback != null)
-            mPreviousCallback.onAttachedToWindow();
-    }
-
-    @Override
-    public void onContentChanged() {
-        if (mPreviousCallback != null)
-            mPreviousCallback.onContentChanged();
-    }
-
-    @Override
-    public boolean onCreatePanelMenu(int featureId, Menu menu) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.onCreatePanelMenu(featureId, menu);
-        return false;
-    }
-
-    @Override
-    public View onCreatePanelView(int featureId) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.onCreatePanelView(featureId);
-        return null;
-    }
-
-    @Override
-    public void onDetachedFromWindow() {
-        if (mPreviousCallback != null)
-            mPreviousCallback.onDetachedFromWindow();
-    }
-
-    @Override
-    public boolean onMenuItemSelected(int featureId, MenuItem item) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.onMenuItemSelected(featureId, item);
-        return false;
-    }
-
-    @Override
-    public boolean onMenuOpened(int featureId, Menu menu) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.onMenuOpened(featureId, menu);
-        return false;
-    }
-
-    @Override
-    public void onPanelClosed(int featureId, Menu menu) {
-        if (mPreviousCallback != null)
-            mPreviousCallback.onPanelClosed(featureId, menu);
-    }
-
-    @Override
-    public boolean onPreparePanel(int featureId, View view, Menu menu) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.onPreparePanel(featureId, view, menu);
-        return false;
-    }
-
-    @Override
-    public boolean onSearchRequested() {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.onSearchRequested();
-        return false;
-    }
-
-    @Override
-    public void onWindowAttributesChanged(LayoutParams attrs) {
-        if (mPreviousCallback != null)
-            mPreviousCallback.onWindowAttributesChanged(attrs);
-    }
-
-    @Override
-    public void onWindowFocusChanged(boolean hasFocus) {
-        if (mPreviousCallback != null)
-            mPreviousCallback.onWindowFocusChanged(hasFocus);
-    }
-
-    @Override
-    public ActionMode onWindowStartingActionMode(Callback callback) {
-        if (mPreviousCallback != null)
-            return mPreviousCallback.onWindowStartingActionMode(callback);
-        return null;
-    }
-}
