diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index d5cd35d..99a4d54 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -202,7 +202,7 @@
     private boolean mShouldSwitchToLastSubtype = true;
 
     private UserDictionary mUserDictionary;
-    private UserBigramDictionary mUserBigramDictionary;
+    private UserHistoryDictionary mUserHistoryDictionary;
     private boolean mIsUserDictionaryAvailable;
 
     private LastComposedWord mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD;
@@ -526,11 +526,9 @@
 
         resetContactsDictionary(oldContactsDictionary);
 
-        // TODO: rename UserBigramDictionary into UserHistoryDictionary
-        mUserBigramDictionary
-                = new UserBigramDictionary(this, this, localeStr, Suggest.DIC_USER_BIGRAM);
-        mSuggest.setUserUnigramDictionary(mUserBigramDictionary);
-        mSuggest.setUserBigramDictionary(mUserBigramDictionary);
+        mUserHistoryDictionary
+                = new UserHistoryDictionary(this, this, localeStr, Suggest.DIC_USER_HISTORY);
+        mSuggest.setUserHistoryDictionary(mUserHistoryDictionary);
 
         LocaleUtils.setSystemLocale(res, savedLocale);
     }
@@ -772,7 +770,7 @@
 
         KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
         if (inputView != null) inputView.closing();
-        if (mUserBigramDictionary != null) mUserBigramDictionary.flushPendingWrites();
+        if (mUserHistoryDictionary != null) mUserHistoryDictionary.flushPendingWrites();
     }
 
     private void onFinishInputViewInternal(boolean finishingInput) {
@@ -1990,9 +1988,6 @@
         setSuggestionStripShown(isSuggestionsStripVisible());
     }
 
-    /**
-     * Adds to the UserBigramDictionary and/or UserUnigramDictionary
-     */
     private void addToUserHistoryDictionary(final CharSequence suggestion) {
         if (suggestion == null || suggestion.length() < 1) return;
 
@@ -2004,16 +1999,16 @@
             return;
         }
 
-        if (mUserBigramDictionary != null) {
-            mUserBigramDictionary.addUnigram(suggestion.toString());
+        if (mUserHistoryDictionary != null) {
             final InputConnection ic = getCurrentInputConnection();
+            final CharSequence prevWord;
             if (null != ic) {
-                final CharSequence prevWord =
-                        EditingUtils.getPreviousWord(ic, mSettingsValues.mWordSeparators);
-                if (null != prevWord) {
-                    mUserBigramDictionary.addBigramPair(prevWord.toString(), suggestion.toString());
-                }
+                prevWord = EditingUtils.getPreviousWord(ic, mSettingsValues.mWordSeparators);
+            } else {
+                prevWord = null;
             }
+            mUserHistoryDictionary.addToUserHistory(null == prevWord ? null : prevWord.toString(),
+                    suggestion.toString());
         }
     }
 
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 08f0e42..9ae2506 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -62,9 +62,8 @@
     public static final int DIC_USER_TYPED = 0;
     public static final int DIC_MAIN = 1;
     public static final int DIC_USER = 2;
-    public static final int DIC_USER_UNIGRAM = 3;
+    public static final int DIC_USER_HISTORY = 3;
     public static final int DIC_CONTACTS = 4;
-    public static final int DIC_USER_BIGRAM = 5;
     public static final int DIC_WHITELIST = 6;
     // If you add a type of dictionary, increment DIC_TYPE_LAST_ID
     // TODO: this value seems unused. Remove it?
@@ -73,10 +72,10 @@
     public static final String DICT_KEY_CONTACTS = "contacts";
     // User dictionary, the system-managed one.
     public static final String DICT_KEY_USER = "user";
-    // User unigram dictionary, internal to LatinIME
-    public static final String DICT_KEY_USER_UNIGRAM = "user_unigram";
-    // User bigram dictionary, internal to LatinIME
-    public static final String DICT_KEY_USER_BIGRAM = "user_bigram";
+    // User history dictionary for the unigram map, internal to LatinIME
+    public static final String DICT_KEY_USER_HISTORY_UNIGRAM = "history_unigram";
+    // User history dictionary for the bigram map, internal to LatinIME
+    public static final String DICT_KEY_USER_HISTORY_BIGRAM = "history_bigram";
     public static final String DICT_KEY_WHITELIST ="whitelist";
 
     private static final boolean DBG = LatinImeLogger.sDBG;
@@ -203,12 +202,11 @@
         addOrReplaceDictionary(mBigramDictionaries, DICT_KEY_CONTACTS, contactsDictionary);
     }
 
-    public void setUserUnigramDictionary(Dictionary userUnigramDictionary) {
-        addOrReplaceDictionary(mUnigramDictionaries, DICT_KEY_USER_UNIGRAM, userUnigramDictionary);
-    }
-
-    public void setUserBigramDictionary(Dictionary userBigramDictionary) {
-        addOrReplaceDictionary(mBigramDictionaries, DICT_KEY_USER_BIGRAM, userBigramDictionary);
+    public void setUserHistoryDictionary(Dictionary userHistoryDictionary) {
+        addOrReplaceDictionary(mUnigramDictionaries, DICT_KEY_USER_HISTORY_UNIGRAM,
+                userHistoryDictionary);
+        addOrReplaceDictionary(mBigramDictionaries, DICT_KEY_USER_HISTORY_BIGRAM,
+                userHistoryDictionary);
     }
 
     public void setAutoCorrectionThreshold(double threshold) {
@@ -347,7 +345,7 @@
             // At second character typed, search the unigrams (scores being affected by bigrams)
             for (final String key : mUnigramDictionaries.keySet()) {
                 // Skip UserUnigramDictionary and WhitelistDictionary to lookup
-                if (key.equals(DICT_KEY_USER_UNIGRAM) || key.equals(DICT_KEY_WHITELIST))
+                if (key.equals(DICT_KEY_USER_HISTORY_UNIGRAM) || key.equals(DICT_KEY_WHITELIST))
                     continue;
                 final Dictionary dictionary = mUnigramDictionaries.get(key);
                 dictionary.getWords(wordComposerForLookup, this, proximityInfo);
diff --git a/java/src/com/android/inputmethod/latin/UserBigramDictionary.java b/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java
similarity index 92%
rename from java/src/com/android/inputmethod/latin/UserBigramDictionary.java
rename to java/src/com/android/inputmethod/latin/UserHistoryDictionary.java
index 91f84be..4e79846 100644
--- a/java/src/com/android/inputmethod/latin/UserBigramDictionary.java
+++ b/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java
@@ -24,7 +24,6 @@
 import android.database.sqlite.SQLiteQueryBuilder;
 import android.os.AsyncTask;
 import android.provider.BaseColumns;
-import android.text.TextUtils;
 import android.util.Log;
 
 import java.util.HashMap;
@@ -32,12 +31,11 @@
 import java.util.Iterator;
 
 /**
- * Stores all the pairs user types in databases. Prune the database if the size
- * gets too big. Unlike AutoDictionary, it even stores the pairs that are already
- * in the dictionary.
+ * Locally gathers stats about the words user types and various other signals like auto-correction
+ * cancellation or manual picks. This allows the keyboard to adapt to the typist over time.
  */
-public class UserBigramDictionary extends ExpandableDictionary {
-    private static final String TAG = "UserBigramDictionary";
+public class UserHistoryDictionary extends ExpandableDictionary {
+    private static final String TAG = "UserHistoryDictionary";
 
     /** Any pair being typed or picked */
     private static final int FREQUENCY_FOR_TYPED = 2;
@@ -46,14 +44,14 @@
     private static final int FREQUENCY_MAX = 127;
 
     /** Maximum number of pairs. Pruning will start when databases goes above this number. */
-    private static int sMaxUserBigrams = 10000;
+    private static int sMaxHistoryBigrams = 10000;
 
     /**
      * When it hits maximum bigram pair, it will delete until you are left with
-     * only (sMaxUserBigrams - sDeleteUserBigrams) pairs.
+     * only (sMaxHistoryBigrams - sDeleteHistoryBigrams) pairs.
      * Do not keep this number small to avoid deleting too often.
      */
-    private static int sDeleteUserBigrams = 1000;
+    private static int sDeleteHistoryBigrams = 1000;
 
     /**
      * Database version should increase if the database structure changes
@@ -65,7 +63,7 @@
     /** Name of the words table in the database */
     private static final String MAIN_TABLE_NAME = "main";
     // TODO: Consume less space by using a unique id for locale instead of the whole
-    // 2-5 character string. (Same TODO from AutoDictionary)
+    // 2-5 character string.
     private static final String MAIN_COLUMN_ID = BaseColumns._ID;
     private static final String MAIN_COLUMN_WORD1 = "word1";
     private static final String MAIN_COLUMN_WORD2 = "word2";
@@ -133,15 +131,15 @@
         }
     }
 
-    public void setDatabaseMax(int maxUserBigram) {
-        sMaxUserBigrams = maxUserBigram;
+    public void setDatabaseMax(int maxHistoryBigram) {
+        sMaxHistoryBigrams = maxHistoryBigram;
     }
 
-    public void setDatabaseDelete(int deleteUserBigram) {
-        sDeleteUserBigrams = deleteUserBigram;
+    public void setDatabaseDelete(int deleteHistoryBigram) {
+        sDeleteHistoryBigrams = deleteHistoryBigram;
     }
 
-    public UserBigramDictionary(Context context, LatinIME ime, String locale, int dicTypeId) {
+    public UserHistoryDictionary(Context context, LatinIME ime, String locale, int dicTypeId) {
         super(context, dicTypeId);
         mIme = ime;
         mLocale = locale;
@@ -173,16 +171,6 @@
     }
 
     /**
-     * Add a single word without context.
-     *
-     * This is a temporary method to match the interface to UserUnigramDictionary. In the end
-     * this should be merged with addBigramPair.
-     */
-    public void addUnigram(final String newWord) {
-        addBigramPair(null, newWord);
-    }
-
-    /**
      * Pair will be added to the user history dictionary.
      *
      * The first word may be null. That means we don't know the context, in other words,
@@ -190,11 +178,12 @@
      * context, as in beginning of a sentence for example.
      * The second word may not be null (a NullPointerException would be thrown).
      */
-    public int addBigramPair(final String word1, String word2) {
+    public int addToUserHistory(final String word1, String word2) {
         // remove caps if second word is autocapitalized
         if (mIme != null && mIme.isAutoCapitalized()) {
             word2 = Character.toLowerCase(word2.charAt(0)) + word2.substring(1);
         }
+        super.addWord(word2, FREQUENCY_FOR_TYPED);
         // Do not insert a word as a bigram of itself
         if (word2.equals(word1)) {
             return 0;
@@ -203,7 +192,6 @@
         int freq;
         if (null == word1) {
             freq = FREQUENCY_FOR_TYPED;
-            super.addWord(word2, FREQUENCY_FOR_TYPED);
         } else {
             freq = super.addBigram(word1, word2, FREQUENCY_FOR_TYPED);
         }
@@ -366,8 +354,8 @@
             try {
                 int totalRowCount = c.getCount();
                 // prune out old data if we have too much data
-                if (totalRowCount > sMaxUserBigrams) {
-                    int numDeleteRows = (totalRowCount - sMaxUserBigrams) + sDeleteUserBigrams;
+                if (totalRowCount > sMaxHistoryBigrams) {
+                    int numDeleteRows = (totalRowCount - sMaxHistoryBigrams) + sDeleteHistoryBigrams;
                     int pairIdColumnId = c.getColumnIndex(FREQ_COLUMN_PAIR_ID);
                     c.moveToFirst();
                     int count = 0;
