diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index 38d904a..a87ff98 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -29,7 +29,7 @@
 import com.android.inputmethod.compat.MotionEventCompatUtils;
 import com.android.inputmethod.keyboard.Key;
 import com.android.inputmethod.keyboard.KeyDetector;
-import com.android.inputmethod.keyboard.LatinKeyboardBaseView;
+import com.android.inputmethod.keyboard.KeyboardView;
 import com.android.inputmethod.keyboard.PointerTracker;
 
 public class AccessibleKeyboardViewProxy {
@@ -40,7 +40,7 @@
     private static final long DELAY_KEY_PRESS = 10;
 
     private int mScaledEdgeSlop;
-    private LatinKeyboardBaseView mView;
+    private KeyboardView mView;
     private AccessibleKeyboardActionListener mListener;
     private FlickGestureDetector mGestureDetector;
 
@@ -57,7 +57,7 @@
         return sInstance;
     }
 
-    public static void setView(LatinKeyboardBaseView view) {
+    public static void setView(KeyboardView view) {
         sInstance.mView = view;
     }
 
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index f3e023d..d1345db 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -72,7 +72,7 @@
  * @attr ref R.styleable#KeyboardView_shadowColor
  * @attr ref R.styleable#KeyboardView_shadowRadius
  */
-public class KeyboardView extends View implements PointerTracker.UIProxy {
+public class KeyboardView extends View implements PointerTracker.DrawingProxy {
     private static final boolean DEBUG_KEYBOARD_GRID = false;
 
     // Miscellaneous constants
@@ -123,13 +123,13 @@
     private static final int MEASURESPEC_UNSPECIFIED = MeasureSpec.makeMeasureSpec(
             0, MeasureSpec.UNSPECIFIED);
 
-    private final UIHandler mHandler = new UIHandler(this);
+    private final DrawingHandler mDrawingHandler = new DrawingHandler(this);
 
-    public static class UIHandler extends StaticInnerHandlerWrapper<KeyboardView> {
+    public static class DrawingHandler extends StaticInnerHandlerWrapper<KeyboardView> {
         private static final int MSG_SHOW_KEY_PREVIEW = 1;
         private static final int MSG_DISMISS_KEY_PREVIEW = 2;
 
-        public UIHandler(KeyboardView outerInstance) {
+        public DrawingHandler(KeyboardView outerInstance) {
             super(outerInstance);
         }
 
@@ -365,7 +365,7 @@
      */
     public void setKeyboard(Keyboard keyboard) {
         // Remove any pending messages, except dismissing preview
-        mHandler.cancelAllShowKeyPreviews();
+        mDrawingHandler.cancelAllShowKeyPreviews();
         mKeyboard = keyboard;
         LatinImeLogger.onSetKeyboard(keyboard);
         requestLayout();
@@ -766,13 +766,13 @@
     }
 
     public void cancelAllMessages() {
-        mHandler.cancelAllMessages();
+        mDrawingHandler.cancelAllMessages();
     }
 
     @Override
     public void showKeyPreview(int keyIndex, PointerTracker tracker) {
         if (mShowKeyPreviewPopup) {
-            mHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
+            mDrawingHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker);
         } else if (mKeyboard.needSpacebarPreview(keyIndex)) {
             // Show key preview (in this case, slide language switcher) without any delay.
             showKey(keyIndex, tracker);
@@ -781,14 +781,14 @@
 
     @Override
     public void cancelShowKeyPreview(PointerTracker tracker) {
-        mHandler.cancelShowKeyPreview(tracker);
+        mDrawingHandler.cancelShowKeyPreview(tracker);
     }
 
     @Override
     public void dismissKeyPreview(PointerTracker tracker) {
         if (mShowKeyPreviewPopup) {
-            mHandler.cancelShowKeyPreview(tracker);
-            mHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
+            mDrawingHandler.cancelShowKeyPreview(tracker);
+            mDrawingHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
         } else if (mKeyboard.needSpacebarPreview(KeyDetector.NOT_A_KEY)) {
             // Dismiss key preview (in this case, slide language switcher) without any delay.
             mPreviewText.setVisibility(View.INVISIBLE);
@@ -821,7 +821,7 @@
         if (key == null)
             return;
 
-        mHandler.cancelAllDismissKeyPreviews();
+        mDrawingHandler.cancelAllDismissKeyPreviews();
         final KeyPreviewDrawParams params = mKeyPreviewDrawParams;
         final int keyDrawX = key.mX + key.mVisualInsetsLeft;
         final int keyDrawWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
index 5ef40ec..c8cfb43 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
@@ -88,17 +88,17 @@
     private final int mSwipeThreshold;
     private final boolean mDisambiguateSwipe;
 
-    private final UIHandler mHandler = new UIHandler(this);
+    private final KeyTimerHandler mKeyTimerHandler = new KeyTimerHandler(this);
 
-    public static class UIHandler extends StaticInnerHandlerWrapper<LatinKeyboardBaseView> {
-        private static final int MSG_REPEAT_KEY = 3;
-        private static final int MSG_LONGPRESS_KEY = 4;
-        private static final int MSG_LONGPRESS_SHIFT_KEY = 5;
-        private static final int MSG_IGNORE_DOUBLE_TAP = 6;
+    public static class KeyTimerHandler extends StaticInnerHandlerWrapper<LatinKeyboardBaseView> {
+        private static final int MSG_REPEAT_KEY = 1;
+        private static final int MSG_LONGPRESS_KEY = 2;
+        private static final int MSG_LONGPRESS_SHIFT_KEY = 3;
+        private static final int MSG_IGNORE_DOUBLE_TAP = 4;
 
         private boolean mInKeyRepeat;
 
-        public UIHandler(LatinKeyboardBaseView outerInstance) {
+        public KeyTimerHandler(LatinKeyboardBaseView outerInstance) {
             super(outerInstance);
         }
 
@@ -249,7 +249,7 @@
                         // Detected a double tap on shift key. If we are in the ignoring double tap
                         // mode, it means we have already turned off caps lock in
                         // {@link KeyboardSwitcher#onReleaseShift} .
-                        final boolean ignoringDoubleTap = mHandler.isIgnoringDoubleTap();
+                        final boolean ignoringDoubleTap = mKeyTimerHandler.isIgnoringDoubleTap();
                         if (!ignoringDoubleTap)
                             onDoubleTapShiftKey(tracker);
                         return true;
@@ -272,7 +272,7 @@
 
     public void startIgnoringDoubleTap() {
         if (ENABLE_CAPSLOCK_BY_DOUBLETAP)
-            mHandler.startIgnoringDoubleTap();
+            mKeyTimerHandler.startIgnoringDoubleTap();
     }
 
     public void setOnKeyboardActionListener(KeyboardActionListener listener) {
@@ -303,7 +303,7 @@
             dismissAllKeyPreviews();
         }
         // Remove any pending messages, except dismissing preview
-        mHandler.cancelKeyTimers();
+        mKeyTimerHandler.cancelKeyTimers();
         super.setKeyboard(keyboard);
         mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(),
                 -getPaddingTop() + mVerticalCorrection);
@@ -349,7 +349,7 @@
 
     @Override
     public void cancelAllMessages() {
-        mHandler.cancelAllMessages();
+        mKeyTimerHandler.cancelAllMessages();
         super.cancelAllMessages();
     }
 
@@ -481,7 +481,8 @@
         // Create pointer trackers until we can get 'id+1'-th tracker, if needed.
         for (int i = pointers.size(); i <= id; i++) {
             final PointerTracker tracker =
-                new PointerTracker(i, this, mHandler, mKeyDetector, this);
+                new PointerTracker(i, getContext(), mKeyTimerHandler, mKeyDetector, this,
+                        mHasDistinctMultitouch);
             if (keyboard != null)
                 tracker.setKeyboard(keyboard, mKeyDetector);
             if (listener != null)
@@ -506,6 +507,7 @@
 
     @Override
     public boolean onTouchEvent(MotionEvent me) {
+        final boolean nonDistinctMultitouch = !mHasDistinctMultitouch;
         final int action = me.getActionMasked();
         final int pointerCount = me.getPointerCount();
         final int oldPointerCount = mOldPointerCount;
@@ -514,7 +516,7 @@
         // TODO: cleanup this code into a multi-touch to single-touch event converter class?
         // If the device does not have distinct multi-touch support panel, ignore all multi-touch
         // events except a transition from/to single-touch.
-        if (!mHasDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
+        if (nonDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
             return true;
         }
 
@@ -525,7 +527,7 @@
         if (mPopupMiniKeyboardPanel == null && mGestureDetector != null
                 && mGestureDetector.onTouchEvent(me)) {
             dismissAllKeyPreviews();
-            mHandler.cancelKeyTimers();
+            mKeyTimerHandler.cancelKeyTimers();
             return true;
         }
 
@@ -541,12 +543,12 @@
             return mPopupMiniKeyboardPanel.onTouchEvent(me);
         }
 
-        if (mHandler.isInKeyRepeat()) {
+        if (mKeyTimerHandler.isInKeyRepeat()) {
             final PointerTracker tracker = getPointerTracker(id);
             // Key repeating timer will be canceled if 2 or more keys are in action, and current
             // event (UP or DOWN) is non-modifier key.
             if (pointerCount > 1 && !tracker.isModifier()) {
-                mHandler.cancelKeyRepeatTimer();
+                mKeyTimerHandler.cancelKeyRepeatTimer();
             }
             // Up event will pass through.
         }
@@ -554,7 +556,7 @@
         // TODO: cleanup this code into a multi-touch to single-touch event converter class?
         // Translate mutli-touch event to single-touch events on the device that has no distinct
         // multi-touch panel.
-        if (!mHasDistinctMultitouch) {
+        if (nonDistinctMultitouch) {
             // Use only main (id=0) pointer tracker.
             PointerTracker tracker = getPointerTracker(0);
             if (pointerCount == 1 && oldPointerCount == 2) {
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index ed93978..4ceabff 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -16,12 +16,13 @@
 
 package com.android.inputmethod.keyboard;
 
+import android.content.Context;
 import android.content.res.Resources;
 import android.os.SystemClock;
 import android.util.Log;
 import android.view.MotionEvent;
 
-import com.android.inputmethod.keyboard.LatinKeyboardBaseView.UIHandler;
+import com.android.inputmethod.keyboard.LatinKeyboardBaseView.KeyTimerHandler;
 import com.android.inputmethod.keyboard.internal.PointerTrackerKeyState;
 import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
 import com.android.inputmethod.latin.LatinImeLogger;
@@ -39,7 +40,7 @@
     private static final boolean DEBUG_LISTENER = false;
     private static boolean DEBUG_MODE = LatinImeLogger.sDBG;
 
-    public interface UIProxy {
+    public interface DrawingProxy {
         public void invalidateKey(Key key);
         public void showKeyPreview(int keyIndex, PointerTracker tracker);
         public void cancelShowKeyPreview(PointerTracker tracker);
@@ -53,9 +54,8 @@
     private final int mLongPressKeyTimeout;
     private final int mLongPressShiftKeyTimeout;
 
-    private final LatinKeyboardBaseView mKeyboardView;
-    private final UIProxy mProxy;
-    private final UIHandler mHandler;
+    private final DrawingProxy mDrawingProxy;
+    private final KeyTimerHandler mKeyTimerHandler;
     private KeyDetector mKeyDetector;
     private KeyboardActionListener mListener = EMPTY_LISTENER;
     private final KeyboardSwitcher mKeyboardSwitcher;
@@ -111,19 +111,18 @@
         public void onSwipeDown() {}
     };
 
-    public PointerTracker(int id, LatinKeyboardBaseView keyboardView, UIHandler handler,
-            KeyDetector keyDetector, UIProxy proxy) {
-        if (proxy == null || handler == null || keyDetector == null)
+    public PointerTracker(int id, Context context, KeyTimerHandler keyTimerHandler,
+            KeyDetector keyDetector, DrawingProxy drawingProxy, boolean hasDistinctMultitouch) {
+        if (drawingProxy == null || keyTimerHandler == null || keyDetector == null)
             throw new NullPointerException();
         mPointerId = id;
-        mKeyboardView = keyboardView;
-        mProxy = proxy;
-        mHandler = handler;
+        mDrawingProxy = drawingProxy;
+        mKeyTimerHandler = keyTimerHandler;
         mKeyDetector = keyDetector;
         mKeyboardSwitcher = KeyboardSwitcher.getInstance();
         mKeyState = new PointerTrackerKeyState(keyDetector);
-        mHasDistinctMultitouch = keyboardView.hasDistinctMultitouch();
-        final Resources res = mKeyboardView.getResources();
+        mHasDistinctMultitouch = hasDistinctMultitouch;
+        final Resources res = context.getResources();
         mConfigSlidingKeyInputEnabled = res.getBoolean(R.bool.config_sliding_key_input_enabled);
         mDelayBeforeKeyRepeatStart = res.getInteger(R.integer.config_delay_before_key_repeat_start);
         mLongPressKeyTimeout = res.getInteger(R.integer.config_long_press_key_timeout);
@@ -262,7 +261,7 @@
         final Key key = getKey(keyIndex);
         if (key != null) {
             key.onReleased();
-            mProxy.invalidateKey(key);
+            mDrawingProxy.invalidateKey(key);
         }
     }
 
@@ -270,7 +269,7 @@
         final Key key = getKey(keyIndex);
         if (key != null && key.isEnabled()) {
             key.onPressed();
-            mProxy.invalidateKey(key);
+            mDrawingProxy.invalidateKey(key);
         }
     }
 
@@ -404,7 +403,7 @@
                 setReleasedKeyGraphics(oldKeyIndex);
                 callListenerOnRelease(oldKey, oldKey.mCode, true);
                 startSlidingKeyInput(oldKey);
-                mHandler.cancelKeyTimers();
+                mKeyTimerHandler.cancelKeyTimers();
                 startRepeatKey(keyIndex);
                 if (mIsAllowedSlidingKeyInput) {
                     // This onPress call may have changed keyboard layout. Those cases are detected
@@ -462,7 +461,7 @@
                 setReleasedKeyGraphics(oldKeyIndex);
                 callListenerOnRelease(oldKey, oldKey.mCode, true);
                 startSlidingKeyInput(oldKey);
-                mHandler.cancelLongPressTimers();
+                mKeyTimerHandler.cancelLongPressTimers();
                 if (mIsAllowedSlidingKeyInput) {
                     keyState.onMoveToNewKey(keyIndex, x, y);
                 } else {
@@ -503,8 +502,8 @@
 
     private void onUpEventInternal(int x, int y, long eventTime,
             boolean updateReleasedKeyGraphics) {
-        mHandler.cancelKeyTimers();
-        mProxy.cancelShowKeyPreview(this);
+        mKeyTimerHandler.cancelKeyTimers();
+        mDrawingProxy.cancelShowKeyPreview(this);
         mIsInSlidingKeyInput = false;
         final PointerTrackerKeyState keyState = mKeyState;
         final int keyX, keyY;
@@ -563,8 +562,8 @@
     }
 
     private void onCancelEventInternal() {
-        mHandler.cancelKeyTimers();
-        mProxy.cancelShowKeyPreview(this);
+        mKeyTimerHandler.cancelKeyTimers();
+        mDrawingProxy.cancelShowKeyPreview(this);
         dismissKeyPreview();
         setReleasedKeyGraphics(mKeyState.getKeyIndex());
         mIsInSlidingKeyInput = false;
@@ -575,7 +574,7 @@
         if (key != null && key.mRepeatable) {
             dismissKeyPreview();
             onRepeatKey(keyIndex);
-            mHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
+            mKeyTimerHandler.startKeyRepeatTimer(mDelayBeforeKeyRepeatStart, keyIndex, this);
             mIsRepeatableKey = true;
         } else {
             mIsRepeatableKey = false;
@@ -631,26 +630,26 @@
     private void showKeyPreview(int keyIndex) {
         if (isKeyPreviewNotRequired(keyIndex))
             return;
-        mProxy.showKeyPreview(keyIndex, this);
+        mDrawingProxy.showKeyPreview(keyIndex, this);
     }
 
     private void dismissKeyPreview() {
-        mProxy.dismissKeyPreview(this);
+        mDrawingProxy.dismissKeyPreview(this);
     }
 
     private void startLongPressTimer(int keyIndex) {
         Key key = getKey(keyIndex);
         if (key.mCode == Keyboard.CODE_SHIFT) {
-            mHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this);
+            mKeyTimerHandler.startLongPressShiftTimer(mLongPressShiftKeyTimeout, keyIndex, this);
         } else if (key.hasUppercaseLetter() && mKeyboard.isManualTemporaryUpperCase()) {
             // We need not start long press timer on the key which has manual temporary upper case
             // code defined and the keyboard is in manual temporary upper case mode.
             return;
         } else if (mKeyboardSwitcher.isInMomentarySwitchState()) {
             // We use longer timeout for sliding finger input started from the symbols mode key.
-            mHandler.startLongPressTimer(mLongPressKeyTimeout * 3, keyIndex, this);
+            mKeyTimerHandler.startLongPressTimer(mLongPressKeyTimeout * 3, keyIndex, this);
         } else {
-            mHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
+            mKeyTimerHandler.startLongPressTimer(mLongPressKeyTimeout, keyIndex, this);
         }
     }
 
diff --git a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
index 1885ea1..cc89579 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
@@ -23,7 +23,7 @@
 
 import com.android.inputmethod.keyboard.Key;
 import com.android.inputmethod.keyboard.Keyboard;
-import com.android.inputmethod.keyboard.LatinKeyboardBaseView;
+import com.android.inputmethod.keyboard.KeyboardView;
 import com.android.inputmethod.keyboard.MiniKeyboard;
 import com.android.inputmethod.latin.R;
 
@@ -199,7 +199,7 @@
         }
     }
 
-    public MiniKeyboardBuilder(LatinKeyboardBaseView view, int layoutTemplateResId, Key parentKey,
+    public MiniKeyboardBuilder(KeyboardView view, int layoutTemplateResId, Key parentKey,
             Keyboard parentKeyboard) {
         final Context context = view.getContext();
         mRes = context.getResources();
@@ -223,7 +223,7 @@
         keyboard.setDefaultCoordX(params.getDefaultKeyCoordX() + params.mKeyWidth / 2);
     }
 
-    private static int getMaxKeyWidth(LatinKeyboardBaseView view, CharSequence[] popupCharacters,
+    private static int getMaxKeyWidth(KeyboardView view, CharSequence[] popupCharacters,
             int minKeyWidth) {
         Paint paint = null;
         Rect bounds = null;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 4a81354..a9f34c6 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -66,7 +66,7 @@
 import com.android.inputmethod.keyboard.Keyboard;
 import com.android.inputmethod.keyboard.KeyboardActionListener;
 import com.android.inputmethod.keyboard.KeyboardSwitcher;
-import com.android.inputmethod.keyboard.LatinKeyboardBaseView;
+import com.android.inputmethod.keyboard.KeyboardView;
 import com.android.inputmethod.keyboard.LatinKeyboard;
 import com.android.inputmethod.keyboard.LatinKeyboardView;
 
@@ -655,7 +655,7 @@
     @Override
     public void onWindowHidden() {
         super.onWindowHidden();
-        LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
+        KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
         if (inputView != null) inputView.closing();
     }
 
@@ -668,7 +668,7 @@
 
         mVoiceProxy.flushVoiceInputLogs(mConfigurationChanging);
 
-        LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
+        KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
         if (inputView != null) inputView.closing();
         if (mAutoDictionary != null) mAutoDictionary.flushPendingWrites();
         if (mUserBigramDictionary != null) mUserBigramDictionary.flushPendingWrites();
@@ -677,7 +677,7 @@
     @Override
     public void onFinishInputView(boolean finishingInput) {
         super.onFinishInputView(finishingInput);
-        LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
+        KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
         if (inputView != null) inputView.cancelAllMessages();
         // Remove pending messages related to update suggestions
         mHandler.cancelUpdateSuggestions();
@@ -866,7 +866,7 @@
     @Override
     public void onComputeInsets(InputMethodService.Insets outInsets) {
         super.onComputeInsets(outInsets);
-        final LatinKeyboardBaseView inputView = mKeyboardSwitcher.getKeyboardView();
+        final KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
         if (inputView == null || mCandidateViewContainer == null)
             return;
         final int containerHeight = mCandidateViewContainer.getHeight();
