diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 3250cdd..0a39ab8 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1791,7 +1791,7 @@
 
     private void updateSuggestions() {
         LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
-        ((LatinKeyboard) inputView.getKeyboard()).setPreferredLetters(null);
+        inputView.getLatinKeyboard().setPreferredLetters(null);
 
         // Check if we have a suggestion engine attached.
         if ((mSuggest == null || !isPredictionOn()) && !mVoiceInputHighlighted) {
@@ -1813,7 +1813,7 @@
 
     private void showCorrections(WordAlternatives alternatives) {
         List<CharSequence> stringList = alternatives.getAlternatives();
-        ((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).setPreferredLetters(null);
+        mKeyboardSwitcher.getInputView().getLatinKeyboard().setPreferredLetters(null);
         showSuggestions(stringList, alternatives.getOriginalWord(), false, false);
     }
 
@@ -1829,7 +1829,7 @@
 
         int[] nextLettersFrequencies = mSuggest.getNextLettersFrequencies();
 
-        ((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).setPreferredLetters(
+        mKeyboardSwitcher.getInputView().getLatinKeyboard().setPreferredLetters(
                 nextLettersFrequencies);
 
         boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasMinimalCorrection();
@@ -2018,7 +2018,7 @@
         saveWordInHistory(suggestion);
         mPredicting = false;
         mCommittedLength = suggestion.length();
-        ((LatinKeyboard) inputView.getKeyboard()).setPreferredLetters(null);
+        inputView.getLatinKeyboard().setPreferredLetters(null);
         // If we just corrected a word, then don't show punctuations
         if (!correcting) {
             setNextSuggestions();
@@ -2321,7 +2321,7 @@
 
     public void onRelease(int primaryCode) {
         // Reset any drag flags in the keyboard
-        ((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).keyReleased();
+        mKeyboardSwitcher.getInputView().getLatinKeyboard().keyReleased();
         //vibrate();
         final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
         if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_SHIFT) {
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index 6b46ab8..2bf70bf 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -598,7 +598,7 @@
      * @see #getKeyboard()
      * @param keyboard the keyboard to display in this view
      */
-    public void setKeyboard(BaseKeyboard keyboard) {
+    protected void setKeyboard(BaseKeyboard keyboard) {
         if (mKeyboard != null) {
             dismissKeyPreview();
         }
@@ -626,7 +626,7 @@
      * @return the currently attached keyboard
      * @see #setKeyboard(BaseKeyboard)
      */
-    public BaseKeyboard getKeyboard() {
+    protected BaseKeyboard getKeyboard() {
         return mKeyboard;
     }
 
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java
index 3542899..6672dd2 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java
@@ -40,7 +40,7 @@
     public static final int KEYCODE_PREV_LANGUAGE = -105;
     public static final int KEYCODE_CAPSLOCK = -106;
 
-    private BaseKeyboard mPhoneKeyboard;
+    private LatinKeyboard mPhoneKeyboard;
 
     /** Whether we've started dropping move events because we found a big jump */
     private boolean mDroppingEvents;
@@ -62,13 +62,13 @@
         super(context, attrs, defStyle);
     }
 
-    public void setPhoneKeyboard(BaseKeyboard phoneKeyboard) {
+    public void setPhoneKeyboard(LatinKeyboard phoneKeyboard) {
         mPhoneKeyboard = phoneKeyboard;
     }
 
     @Override
     public void setPreviewEnabled(boolean previewEnabled) {
-        if (getKeyboard() == mPhoneKeyboard) {
+        if (getLatinKeyboard() == mPhoneKeyboard) {
             // Phone keyboard never shows popup preview (except language switch).
             super.setPreviewEnabled(false);
         } else {
@@ -76,8 +76,7 @@
         }
     }
 
-    @Override
-    public void setKeyboard(BaseKeyboard k) {
+    public void setLatinKeyboard(LatinKeyboard k) {
         super.setKeyboard(k);
         // One-seventh of the keyboard width seems like a reasonable threshold
         mJumpThresholdSquare = k.getMinWidth() / 7;
@@ -87,12 +86,21 @@
         setKeyboardLocal(k);
     }
 
+    public LatinKeyboard getLatinKeyboard() {
+        BaseKeyboard keyboard = getKeyboard();
+        if (keyboard instanceof LatinKeyboard) {
+            return (LatinKeyboard)keyboard;
+        } else {
+            return null;
+        }
+    }
+
     @Override
     protected boolean onLongPress(Key key) {
         int primaryCode = key.codes[0];
         if (primaryCode == KEYCODE_OPTIONS) {
             return invokeOnKey(KEYCODE_OPTIONS_LONGPRESS);
-        } else if (primaryCode == '0' && getKeyboard() == mPhoneKeyboard) {
+        } else if (primaryCode == '0' && getLatinKeyboard() == mPhoneKeyboard) {
             // Long pressing on 0 in phone number keypad gives you a '+'.
             return invokeOnKey('+');
         } else {
@@ -109,9 +117,8 @@
 
     @Override
     protected CharSequence adjustCase(CharSequence label) {
-        BaseKeyboard keyboard = getKeyboard();
-        if (keyboard instanceof LatinKeyboard
-                && ((LatinKeyboard) keyboard).isAlphaKeyboard()
+        LatinKeyboard keyboard = getLatinKeyboard();
+        if (keyboard.isAlphaKeyboard()
                 && keyboard.isShifted()
                 && !TextUtils.isEmpty(label) && label.length() < 3
                 && Character.isLowerCase(label.charAt(0))) {
@@ -121,13 +128,10 @@
     }
 
     public boolean setShiftLocked(boolean shiftLocked) {
-        BaseKeyboard keyboard = getKeyboard();
-        if (keyboard instanceof LatinKeyboard) {
-            ((LatinKeyboard)keyboard).setShiftLocked(shiftLocked);
-            invalidateAllKeys();
-            return true;
-        }
-        return false;
+        LatinKeyboard keyboard = getLatinKeyboard();
+        keyboard.setShiftLocked(shiftLocked);
+        invalidateAllKeys();
+        return true;
     }
 
     /**
@@ -209,7 +213,7 @@
 
     @Override
     public boolean onTouchEvent(MotionEvent me) {
-        LatinKeyboard keyboard = (LatinKeyboard) getKeyboard();
+        LatinKeyboard keyboard = getLatinKeyboard();
         if (DEBUG_LINE) {
             mLastX = (int) me.getX();
             mLastY = (int) me.getY();
@@ -258,7 +262,7 @@
     private int mLastY;
     private Paint mPaint;
 
-    private void setKeyboardLocal(BaseKeyboard k) {
+    private void setKeyboardLocal(LatinKeyboard k) {
         if (DEBUG_AUTO_PLAY) {
             findKeys();
             if (mHandler2 == null) {
@@ -319,7 +323,7 @@
     }
 
     private void findKeys() {
-        List<Key> keys = getKeyboard().getKeys();
+        List<Key> keys = getLatinKeyboard().getKeys();
         // Get the keys on this keyboard
         for (int i = 0; i < keys.size(); i++) {
             int code = keys.get(i).codes[0];
