Merge "Contacts binary dictionary updates with change in keyboard locale."
diff --git a/java/res/values-af/strings.xml b/java/res/values-af/strings.xml
index b9c26f8..7431fce 100644
--- a/java/res/values-af/strings.xml
+++ b/java/res/values-af/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Steminvoering"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Glimlag-gesiggie"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Soek"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Punt"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift geaktiveer"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Kasslot geaktiveer"</string>
diff --git a/java/res/values-be/strings.xml b/java/res/values-be/strings.xml
index 803dcbd..4d14565 100644
--- a/java/res/values-be/strings.xml
+++ b/java/res/values-be/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Галасавы ўвод"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Смайлік"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Увод"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Пошук"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Кропка"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift уключаны"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps Lock уключаны"</string>
diff --git a/java/res/values-bg/strings.xml b/java/res/values-bg/strings.xml
index b235e2e..106a918 100644
--- a/java/res/values-bg/strings.xml
+++ b/java/res/values-bg/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Гласово въвеждане"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Усмивка"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Return"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Търсене"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Точка"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"„Shift“ е активиран"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"„Caps Lock“ е активиран"</string>
diff --git a/java/res/values-ca/strings.xml b/java/res/values-ca/strings.xml
index 2387449..e3adbcf 100644
--- a/java/res/values-ca/strings.xml
+++ b/java/res/values-ca/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Entrada de veu"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Cara somrient"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Retorn"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Cerca"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Punt"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Maj activat"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Bloq Maj activat"</string>
diff --git a/java/res/values-cs/strings.xml b/java/res/values-cs/strings.xml
index 530f475..b3e2ca7 100644
--- a/java/res/values-cs/strings.xml
+++ b/java/res/values-cs/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Hlasový vstup"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Smajlík"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"vyhledávací tlačítko"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Tečka"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Klávesa Shift je aktivní"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Klávesa Caps Lock je aktivní"</string>
diff --git a/java/res/values-es/strings.xml b/java/res/values-es/strings.xml
index bcc327f..3c60aa6 100644
--- a/java/res/values-es/strings.xml
+++ b/java/res/values-es/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Entrada de voz"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Emoticono"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Tecla Intro"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Buscar"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Punto"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Mayúsculas habilitadas"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Bloqueo de mayúsculas habilitado"</string>
diff --git a/java/res/values-et/strings.xml b/java/res/values-et/strings.xml
index 25fee55..4a592c3 100644
--- a/java/res/values-et/strings.xml
+++ b/java/res/values-et/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Kõnesisend"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Naerunägu"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Tagasi"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Otsing"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Punkt"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Tõstuklahv on lubatud"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Suurtähelukk on lubatud"</string>
diff --git a/java/res/values-fa/strings.xml b/java/res/values-fa/strings.xml
index ed5d357..bc0e85b 100644
--- a/java/res/values-fa/strings.xml
+++ b/java/res/values-fa/strings.xml
@@ -97,8 +97,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"ورودی صدا"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"صورت متبسم"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Return"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"جستجو"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"نقطه"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift فعال است"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps lock فعال شد"</string>
diff --git a/java/res/values-fi/strings.xml b/java/res/values-fi/strings.xml
index b8b401b..97002ed 100644
--- a/java/res/values-fi/strings.xml
+++ b/java/res/values-fi/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Puheohjaus"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Hymiö"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Haku"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Piste"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Vaihto päällä"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps lock päällä"</string>
diff --git a/java/res/values-hr/strings.xml b/java/res/values-hr/strings.xml
index a639073..a59d469 100644
--- a/java/res/values-hr/strings.xml
+++ b/java/res/values-hr/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Glasovni unos"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Smješko"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Pretraživanje"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Točka"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Omogućena tipka Shift"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Omogućeno pisanje velikih slova"</string>
diff --git a/java/res/values-ja/strings.xml b/java/res/values-ja/strings.xml
index 891beef..3a86516 100644
--- a/java/res/values-ja/strings.xml
+++ b/java/res/values-ja/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"音声入力"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"顔文字"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"検索"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"中点"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift有効"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps lock有効"</string>
diff --git a/java/res/values-lt/strings.xml b/java/res/values-lt/strings.xml
index b093e86..d8c982d 100644
--- a/java/res/values-lt/strings.xml
+++ b/java/res/values-lt/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Įvestis balsu"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Šypsenėlė"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Grįžti"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Ieškoti"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Taškas"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Įgalintas antrasis lygis"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Įgalintos didžiosios raidės"</string>
diff --git a/java/res/values-ms/strings.xml b/java/res/values-ms/strings.xml
index f584f66..a07c44f 100644
--- a/java/res/values-ms/strings.xml
+++ b/java/res/values-ms/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Input suara"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Muka senyum"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Return"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Carian"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Titik"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Kunci anjak didayakan"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Kunci huruf besar didayakan"</string>
diff --git a/java/res/values-nb/strings.xml b/java/res/values-nb/strings.xml
index 158b067..8ed2376 100644
--- a/java/res/values-nb/strings.xml
+++ b/java/res/values-nb/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Taleinndata"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Smilefjes"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Return"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Søk"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Prikk"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift er aktivert"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps Lock er aktivert"</string>
diff --git a/java/res/values-pl/strings.xml b/java/res/values-pl/strings.xml
index c2c7820..bf27782 100644
--- a/java/res/values-pl/strings.xml
+++ b/java/res/values-pl/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Wprowadzanie głosowe"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Uśmiechnięta buźka"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Szukaj"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Punkt"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift włączony"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps lock włączony"</string>
diff --git a/java/res/values-pt/strings.xml b/java/res/values-pt/strings.xml
index d468712..7d64759 100644
--- a/java/res/values-pt/strings.xml
+++ b/java/res/values-pt/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Entrada de voz"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Carinha sorridente"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Voltar"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Pesquisar"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Ponto"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift ativado"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps lock ativado"</string>
diff --git a/java/res/values-ru/strings.xml b/java/res/values-ru/strings.xml
index 3bde146..a9bd6ac 100644
--- a/java/res/values-ru/strings.xml
+++ b/java/res/values-ru/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Голосовой ввод"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Смайлик"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Клавиша \"Ввод\""</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Поиск"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Точка"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Верхний регистр включен"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps Lock включен"</string>
diff --git a/java/res/values-sk/strings.xml b/java/res/values-sk/strings.xml
index b11142c..5b4224d 100644
--- a/java/res/values-sk/strings.xml
+++ b/java/res/values-sk/strings.xml
@@ -60,7 +60,7 @@
     <string name="auto_correction_threshold_mode_off" msgid="8470882665417944026">"Vypnuté"</string>
     <string name="auto_correction_threshold_mode_modest" msgid="8788366690620799097">"Mierne"</string>
     <string name="auto_correction_threshold_mode_aggeressive" msgid="3524029103734923819">"Agresívne"</string>
-    <string name="auto_correction_threshold_mode_very_aggeressive" msgid="3386782235540547678">"Veľmi agresívna"</string>
+    <string name="auto_correction_threshold_mode_very_aggeressive" msgid="3386782235540547678">"Veľmi agresívne"</string>
     <string name="bigram_suggestion" msgid="8169311444438922902">"Návrhy ďalšieho slova"</string>
     <string name="bigram_suggestion_summary" msgid="6635527607242625713">"Na zlepšenie návrhov použiť predchádzajúce slovo"</string>
     <string name="bigram_prediction" msgid="3216364899483135294">"Odhad ďalšieho slova"</string>
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Hlasový vstup"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Usmiata tvár"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"vyhľadávacie tlačidlo"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Bodka"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Kláves Shift je povolený"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Kláves Caps Lock je povolený"</string>
diff --git a/java/res/values-sl/strings.xml b/java/res/values-sl/strings.xml
index ed8c77f..ce7dc70 100644
--- a/java/res/values-sl/strings.xml
+++ b/java/res/values-sl/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Glasovni vnos"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Smeško"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Vračalka"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Iskanje"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Pika"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Način »Shift« je omogočen"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Način »Caps Lock« je omogočen"</string>
diff --git a/java/res/values-sr/strings.xml b/java/res/values-sr/strings.xml
index 950baad..6d2899b 100644
--- a/java/res/values-sr/strings.xml
+++ b/java/res/values-sr/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Гласовни унос"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Смајли"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Return"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Претражи"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Тачка"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift је омогућен"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps lock је омогућен"</string>
diff --git a/java/res/values-tl/strings.xml b/java/res/values-tl/strings.xml
index 75e56ec..7d365b2 100644
--- a/java/res/values-tl/strings.xml
+++ b/java/res/values-tl/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Input ng boses"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Smiley na mukha"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Bumalik"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Paghahanap"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Tuldok"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Pinagana ang shift"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Pinagana ang caps lock"</string>
diff --git a/java/res/values-tr/strings.xml b/java/res/values-tr/strings.xml
index 49c861f..39737f5 100644
--- a/java/res/values-tr/strings.xml
+++ b/java/res/values-tr/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Ses girişi"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Gülen yüz"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Enter"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Ara"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Nokta"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Üst karakter etkin"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Büyük harf kilidi etkin"</string>
diff --git a/java/res/values-uk/strings.xml b/java/res/values-uk/strings.xml
index 9d50634..49889fc 100644
--- a/java/res/values-uk/strings.xml
+++ b/java/res/values-uk/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Голосовий ввід"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Смайлик"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Клавіша Return"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Пошук"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Крапка"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift увімкнено"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Caps Lock увімкнено"</string>
diff --git a/java/res/values-vi/strings.xml b/java/res/values-vi/strings.xml
index 80844c1..753af18 100644
--- a/java/res/values-vi/strings.xml
+++ b/java/res/values-vi/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"Nhập dữ liệu bằng giọng nói"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"Mặt cười"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"Quay lại"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"Tìm kiếm"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"Dấu chấm"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Đã bật Shift"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"Đã bật Caps lock"</string>
diff --git a/java/res/values-zh-rCN/strings.xml b/java/res/values-zh-rCN/strings.xml
index 7ff0364..efde541 100644
--- a/java/res/values-zh-rCN/strings.xml
+++ b/java/res/values-zh-rCN/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"语音输入"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"笑脸"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"返回"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"搜索"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"点"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift 模式已启用"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"大写锁定已启用"</string>
diff --git a/java/res/values-zh-rTW/strings.xml b/java/res/values-zh-rTW/strings.xml
index 9c5d88b..51df022 100644
--- a/java/res/values-zh-rTW/strings.xml
+++ b/java/res/values-zh-rTW/strings.xml
@@ -93,8 +93,7 @@
     <string name="spoken_description_mic" msgid="615536748882611950">"語音輸入"</string>
     <string name="spoken_description_smiley" msgid="2256309826200113918">"笑臉"</string>
     <string name="spoken_description_return" msgid="8178083177238315647">"返回"</string>
-    <!-- no translation found for spoken_description_search (1247236163755920808) -->
-    <skip />
+    <string name="spoken_description_search" msgid="1247236163755920808">"搜尋"</string>
     <string name="spoken_description_dot" msgid="40711082435231673">"點"</string>
     <string name="spoken_description_shiftmode_on" msgid="5700440798609574589">"Shift 鍵已啟用"</string>
     <string name="spoken_description_shiftmode_locked" msgid="593175803181701830">"大寫鎖定已啟用"</string>
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index d51d378..d663b00 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -26,6 +26,8 @@
     <string name="english_ime_settings">Android keyboard settings</string>
     <!-- Title for Latin keyboard input options dialog [CHAR LIMIT=25] -->
     <string name="english_ime_input_options">Input options</string>
+    <!-- Title for Latin keyboard research log dialog, which contains special commands for users that contribute data for research. [CHAR LIMIT=25] -->
+    <string name="english_ime_research_log">Research Log Commands</string>
 
     <!-- Name of Android spell checker service -->
     <string name="spell_checker_service_name">Android spell checker</string>
@@ -233,6 +235,20 @@
     <!-- Title for input language selection screen -->
     <string name="language_selection_title">Input languages</string>
 
+    <!-- Title for dialog option that lets user mark a particular time in the log for later review by experts [CHAR LIMIT=25] -->
+    <string name="note_timestamp_for_researchlog">Note timestamp in log</string>
+    <!-- Toast notification message that the time has been marked for later review. [CHAR LIMIT=25] -->
+    <string name="notify_recorded_timestamp">Recorded timestamp</string>
+
+    <!-- Title for dialog option to let users cancel logging and delete log for this session [CHAR LIMIT=25] -->
+    <string name="do_not_log_this_session">Do not log this session</string>
+    <!-- Toast notification that the system is processing the request to delete the log for this session [CHAR LIMIT=25] -->
+    <string name="notify_session_log_deleting">Deleting session log</string>
+    <!-- Toast notification that the system has successfully deleted the log for this session [CHAR LIMIT=25] -->
+    <string name="notify_session_log_deleted">Session log deleted</string>
+    <!-- Toast notification that the system has failed to delete the log for this session [CHAR LIMIT=25] -->
+    <string name="notify_session_log_not_deleted">Session log NOT deleted</string>
+
     <!-- Preference for input language selection -->
     <string name="select_language">Input languages</string>
 
diff --git a/java/res/xml-sw600dp/key_apostrophe.xml b/java/res/xml-sw600dp/key_apostrophe.xml
index 7da4b62..0c838db 100644
--- a/java/res/xml-sw600dp/key_apostrophe.xml
+++ b/java/res/xml-sw600dp/key_apostrophe.xml
@@ -23,20 +23,11 @@
 >
     <switch>
         <case
-            latin:mode="email"
+            latin:mode="email|url"
         >
             <Key
                 latin:keyLabel="-" />
         </case>
-        <case
-            latin:mode="url"
-        >
-            <Key
-                latin:keyLabel="/"
-                latin:keyHintLabel=":"
-                latin:moreKeys=":"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-        </case>
         <default>
             <Key
                 latin:keyLabel="!text/keylabel_for_apostrophe"
diff --git a/java/res/xml-sw600dp/key_dash.xml b/java/res/xml-sw600dp/key_dash.xml
index f7e0b34..8f91eff 100644
--- a/java/res/xml-sw600dp/key_dash.xml
+++ b/java/res/xml-sw600dp/key_dash.xml
@@ -23,7 +23,7 @@
 >
     <switch>
         <case
-            latin:mode="email"
+            latin:mode="email|url"
         >
             <Key
                 latin:keyLabel="_" />
diff --git a/java/res/xml-sw600dp/key_f1.xml b/java/res/xml-sw600dp/key_f1.xml
new file mode 100644
index 0000000..77afe4e
--- /dev/null
+++ b/java/res/xml-sw600dp/key_f1.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, 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.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <switch>
+        <case
+            latin:keyboardLayoutSetElement="symbols"
+            latin:mode="url"
+        >
+            <Key
+                latin:keyLabel=":" />
+        </case>
+        <case
+            latin:keyboardLayoutSetElement="symbols"
+        >
+            <Key
+                latin:keyLabel="\@" />
+        </case>
+        <!-- keyboardLayoutSetElement != "symbols" -->
+        <case
+            latin:mode="email"
+        >
+            <Key
+                latin:keyLabel="\@" />
+        </case>
+        <case
+            latin:mode="url"
+        >
+            <Key
+                latin:keyLabel="/"
+                latin:keyHintLabel=":"
+                latin:moreKeys=":"
+                latin:keyStyle="hasShiftedLetterHintStyle" />
+        </case>
+        <default>
+            <Key
+                latin:keyLabel="/"
+                latin:keyHintLabel="\@"
+                latin:moreKeys="\@"
+                latin:keyStyle="hasShiftedLetterHintStyle" />
+        </default>
+    </switch>
+</merge>
diff --git a/java/res/xml-sw600dp/key_f2.xml b/java/res/xml-sw600dp/key_f2.xml
new file mode 100644
index 0000000..ca3b30b
--- /dev/null
+++ b/java/res/xml-sw600dp/key_f2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, 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.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <switch>
+        <case
+            latin:mode="email|url"
+        >
+            <Key
+                latin:keyStyle="comKeyStyle" />
+        </case>
+        <case
+            latin:imeAction="actionSearch"
+        >
+            <Key
+                latin:keyLabel=":"
+                latin:keyHintLabel="+"
+                latin:moreKeys="+"
+                latin:keyStyle="hasShiftedLetterHintStyle" />
+        </case>
+        <default>
+            <Key
+                latin:keyStyle="smileyKeyStyle" />
+        </default>
+    </switch>
+</merge>
diff --git a/java/res/xml-sw600dp/key_question_exclamation.xml b/java/res/xml-sw600dp/key_question_exclamation.xml
index f1495de..860a0be 100644
--- a/java/res/xml-sw600dp/key_question_exclamation.xml
+++ b/java/res/xml-sw600dp/key_question_exclamation.xml
@@ -23,20 +23,11 @@
 >
     <switch>
         <case
-            latin:mode="email"
+            latin:mode="email|url"
         >
             <Key
                 latin:keyLabel="-" />
         </case>
-        <case
-            latin:mode="url"
-        >
-            <Key
-                latin:keyLabel="/"
-                latin:keyHintLabel=":"
-                latin:moreKeys=":"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-        </case>
         <default>
             <Key
                 latin:keyLabel="\?"
diff --git a/java/res/xml-sw600dp/keys_f1f2.xml b/java/res/xml-sw600dp/keys_f1f2.xml
deleted file mode 100644
index 721bfc7..0000000
--- a/java/res/xml-sw600dp/keys_f1f2.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2012, 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.
-*/
--->
-
-<merge
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
-    <switch>
-        <case
-            latin:mode="url"
-        >
-            <Key
-                latin:keyStyle="comKeyStyle"
-                latin:keyWidth="18.0%p" />
-        </case>
-        <default>
-            <switch>
-                <case
-                    latin:mode="email"
-                >
-                    <Key
-                        latin:keyStyle="comKeyStyle" />
-                </case>
-                <case
-                    latin:imeAction="actionSearch"
-                >
-                    <Key
-                        latin:keyLabel=":"
-                        latin:keyHintLabel="+"
-                        latin:moreKeys="+"
-                        latin:keyStyle="hasShiftedLetterHintStyle" />
-                </case>
-                <default>
-                    <Key
-                        latin:keyStyle="smileyKeyStyle" />
-                </default>
-            </switch>
-            <switch>
-                <case
-                    latin:mode="email"
-                >
-                    <Key
-                        latin:keyLabel="\@" />
-                </case>
-                <default>
-                    <Key
-                        latin:keyLabel="/"
-                        latin:keyHintLabel="\@"
-                        latin:moreKeys="\@"
-                        latin:keyStyle="hasShiftedLetterHintStyle" />
-                </default>
-            </switch>
-        </default>
-    </switch>
-</merge>
diff --git a/java/res/xml-sw600dp/row_dvorak4.xml b/java/res/xml-sw600dp/row_dvorak4.xml
index ffc3427..47cee45 100644
--- a/java/res/xml-sw600dp/row_dvorak4.xml
+++ b/java/res/xml-sw600dp/row_dvorak4.xml
@@ -23,22 +23,24 @@
 >
     <Row
         latin:keyWidth="9.0%p"
+        backgroundType="functional"
     >
         <Key
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyWidth="10.0%p" />
         <include
-            latin:keyboardLayout="@xml/keys_f1f2" />
+            latin:keyboardLayout="@xml/key_shortcut" />
+        <include
+            latin:keyboardLayout="@xml/key_f1" />
         <include
             latin:keyXPos="28.0%p"
-            latin:keyboardLayout="@xml/key_space" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
         <include
             latin:keyboardLayout="@xml/key_question_exclamation" />
         <include
             latin:keyboardLayout="@xml/key_dash" />
         <include
-            latin:keyXPos="-9.0%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_f2" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw600dp/row_hebrew4.xml b/java/res/xml-sw600dp/row_hebrew4.xml
index 114a5cc..f429f97 100644
--- a/java/res/xml-sw600dp/row_hebrew4.xml
+++ b/java/res/xml-sw600dp/row_hebrew4.xml
@@ -23,20 +23,22 @@
 >
     <Row
         latin:keyWidth="9.0%p"
+        latin:backgroundType="functional"
     >
         <Key
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyWidth="10.0%p" />
         <include
-            latin:keyboardLayout="@xml/keys_f1f2" />
+            latin:keyboardLayout="@xml/key_shortcut" />
+        <include
+            latin:keyboardLayout="@xml/key_f1" />
         <include
             latin:keyXPos="28.0%p"
-            latin:keyboardLayout="@xml/key_space" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
         <include
             latin:keyboardLayout="@xml/keys_comma_period" />
         <include
-            latin:keyXPos="-9.0%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_f2" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw600dp/row_qwerty4.xml b/java/res/xml-sw600dp/row_qwerty4.xml
index a4ba8a4..fa43363 100644
--- a/java/res/xml-sw600dp/row_qwerty4.xml
+++ b/java/res/xml-sw600dp/row_qwerty4.xml
@@ -23,22 +23,24 @@
 >
     <Row
         latin:keyWidth="9.0%p"
+        latin:backgroundType="functional"
     >
         <Key
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyWidth="10.0%p" />
         <include
-            latin:keyboardLayout="@xml/keys_f1f2" />
+            latin:keyboardLayout="@xml/key_shortcut" />
+        <include
+            latin:keyboardLayout="@xml/key_f1" />
         <include
             latin:keyXPos="28.0%p"
-            latin:keyboardLayout="@xml/key_space" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
         <include
             latin:keyboardLayout="@xml/key_apostrophe" />
         <include
             latin:keyboardLayout="@xml/key_dash" />
         <include
-            latin:keyXPos="-9.0%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_f2" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw600dp/row_symbols4.xml b/java/res/xml-sw600dp/row_symbols4.xml
index 20d1a7d..73a5b17 100644
--- a/java/res/xml-sw600dp/row_symbols4.xml
+++ b/java/res/xml-sw600dp/row_symbols4.xml
@@ -23,25 +23,24 @@
 >
     <Row
         latin:keyWidth="9.0%p"
+        latin:backgroundType="functional"
     >
         <Key
             latin:keyStyle="toAlphaKeyStyle"
             latin:keyWidth="10.0%p" />
         <Key
             latin:keyLabel="/" />
-        <Key
-            latin:keyLabel="\@" />
+        <include
+            latin:keyboardLayout="@xml/key_f1" />
         <include
             latin:keyXPos="28.0%p"
-            latin:keyboardLayout="@xml/key_space" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
         <Key
             latin:keyLabel="&quot;"
             latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
         <Key
             latin:keyLabel="_" />
-        <include
-            latin:keyXPos="-9.0%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+        <!-- Here is empty space. -->
     </Row>
 </merge>
diff --git a/java/res/xml-sw600dp/row_symbols_shift4.xml b/java/res/xml-sw600dp/row_symbols_shift4.xml
index fd7b370..6f3aac7 100644
--- a/java/res/xml-sw600dp/row_symbols_shift4.xml
+++ b/java/res/xml-sw600dp/row_symbols_shift4.xml
@@ -23,16 +23,16 @@
 >
     <Row
         latin:keyWidth="9.0%p"
+        latin:backgroundType="functional"
     >
         <Key
             latin:keyStyle="toAlphaKeyStyle"
             latin:keyWidth="10.0%p" />
+        <!-- Here is empty space. -->
         <include
             latin:keyXPos="28.0%p"
-            latin:keyboardLayout="@xml/key_space" />
-        <include
-            latin:keyXPos="-9.0%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
+        <!-- Here is empty space. -->
     </Row>
 </merge>
diff --git a/java/res/xml-sw600dp/rows_number_normal.xml b/java/res/xml-sw600dp/rows_number_normal.xml
index 3954b00..48b3040 100644
--- a/java/res/xml-sw600dp/rows_number_normal.xml
+++ b/java/res/xml-sw600dp/rows_number_normal.xml
@@ -25,15 +25,18 @@
         <Key
             latin:keyLabel="-"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="+"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="."
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="1"
             latin:keyStyle="numKeyStyle"
@@ -52,11 +55,13 @@
     <Row>
         <Key
             latin:keyStyle="numStarKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="/"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <switch>
             <case
                 latin:mode="time|datetime"
@@ -66,13 +71,15 @@
                     latin:keyLabelFlags="hasPopupHint"
                     latin:moreKeys="!text/more_keys_for_am_pm"
                     latin:keyStyle="numKeyStyle"
-                    latin:keyWidth="10%p" />
+                    latin:keyWidth="10%p"
+                    latin:backgroundType="functional" />
             </case>
             <default>
                 <Key
                     latin:keyLabel=","
                     latin:keyStyle="numKeyStyle"
-                    latin:keyWidth="10%p" />
+                    latin:keyWidth="10%p"
+                    latin:backgroundType="functional" />
             </default>
         </switch>
         <Key
@@ -94,11 +101,13 @@
         <Key
             latin:keyLabel="("
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel=")"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <switch>
             <case
                 latin:mode="time|datetime"
@@ -106,13 +115,15 @@
                 <Key
                     latin:keyLabel=":"
                     latin:keyStyle="numKeyStyle"
-                    latin:keyWidth="10%p" />
+                    latin:keyWidth="10%p"
+                    latin:backgroundType="functional" />
             </case>
             <default>
                 <Key
                     latin:keyLabel="="
                     latin:keyStyle="numKeyStyle"
-                    latin:keyWidth="10%p" />
+                    latin:keyWidth="10%p"
+                    latin:backgroundType="functional" />
             </default>
         </switch>
         <Key
@@ -131,7 +142,8 @@
     <Row>
         <Key
             latin:keyStyle="spaceKeyStyle"
-            latin:keyWidth="30%p" />
+            latin:keyWidth="30%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="numStarKeyStyle"
             latin:keyXPos="31%p" />
@@ -141,9 +153,5 @@
         <Key
             latin:keyLabel="#"
             latin:keyStyle="numKeyStyle" />
-        <include
-            latin:keyXPos="-10%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw600dp/rows_phone.xml b/java/res/xml-sw600dp/rows_phone.xml
index 113ce1f..dcc4fde 100644
--- a/java/res/xml-sw600dp/rows_phone.xml
+++ b/java/res/xml-sw600dp/rows_phone.xml
@@ -29,14 +29,17 @@
         <Key
             latin:keyLabel="-"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="+"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="numPauseKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="num1KeyStyle"
             latin:keyXPos="31%p" />
@@ -53,14 +56,17 @@
         <Key
             latin:keyLabel=","
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="."
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="numWaitKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="num4KeyStyle"
             latin:keyXPos="31%p" />
@@ -77,15 +83,18 @@
         <Key
             latin:keyLabel="("
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel=")"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="N"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="10%p" />
+            latin:keyWidth="10%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="num7KeyStyle"
             latin:keyXPos="31%p" />
@@ -99,7 +108,8 @@
     <Row>
         <Key
             latin:keyStyle="spaceKeyStyle"
-            latin:keyWidth="30%p" />
+            latin:keyWidth="30%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="numStarKeyStyle"
             latin:keyXPos="31%p" />
@@ -108,9 +118,5 @@
         <Key
             latin:keyLabel="#"
             latin:keyStyle="numKeyStyle" />
-        <include
-            latin:keyXPos="-10%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw768dp/key_settings.xml b/java/res/xml-sw768dp/key_settings.xml
index 0359a99..0d3bb59 100644
--- a/java/res/xml-sw768dp/key_settings.xml
+++ b/java/res/xml-sw768dp/key_settings.xml
@@ -32,4 +32,4 @@
             <Spacer />
         </default>
     </switch>
- </merge>
+</merge>
diff --git a/java/res/xml-sw768dp/key_shortcut.xml b/java/res/xml-sw768dp/key_shortcut.xml
index 9052705..2d09ebb 100644
--- a/java/res/xml-sw768dp/key_shortcut.xml
+++ b/java/res/xml-sw768dp/key_shortcut.xml
@@ -28,5 +28,9 @@
             <Key
                 latin:keyStyle="shortcutKeyStyle" />
         </case>
+        <default>
+            <!-- The empty space instead of shortcut key. -->
+            <Spacer />
+        </default>
     </switch>
 </merge>
diff --git a/java/res/xml-sw768dp/key_styles_common.xml b/java/res/xml-sw768dp/key_styles_common.xml
index f2fb90b..40082ac 100644
--- a/java/res/xml-sw768dp/key_styles_common.xml
+++ b/java/res/xml-sw768dp/key_styles_common.xml
@@ -74,12 +74,6 @@
     <include
         latin:keyboardLayout="@xml/key_styles_enter" />
     <key-style
-        latin:styleName="defaultActionKeyStyle"
-        latin:code="!code/key_action_enter"
-        latin:keyIcon="!icon/undefined"
-        latin:backgroundType="functional"
-        latin:parentStyle="defaultEnterKeyStyle" />
-    <key-style
         latin:styleName="spaceKeyStyle"
         latin:code="!code/key_space"
         latin:keyActionFlags="noKeyPreview" />
diff --git a/java/res/xml-sw768dp/keys_f1f2.xml b/java/res/xml-sw768dp/keys_f1f2.xml
deleted file mode 100644
index 5697035..0000000
--- a/java/res/xml-sw768dp/keys_f1f2.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2012, 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.
-*/
--->
-
-<merge
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
-    <switch>
-        <case
-            latin:mode="url"
-        >
-            <Key
-                latin:keyStyle="comKeyStyle"
-                latin:keyWidth="16.084%p" />
-        </case>
-        <default>
-            <switch>
-                <case
-                    latin:mode="email"
-                >
-                    <Key
-                        latin:keyStyle="comKeyStyle" />
-                </case>
-                <case
-                    latin:imeAction="actionSearch"
-                >
-                    <Key
-                        latin:keyLabel=":"
-                        latin:keyHintLabel="+"
-                        latin:moreKeys="+"
-                        latin:keyStyle="hasShiftedLetterHintStyle" />
-                </case>
-                <default>
-                    <Key
-                        latin:keyStyle="smileyKeyStyle" />
-                </default>
-            </switch>
-            <switch>
-                <case
-                    latin:mode="email"
-                >
-                    <Key
-                        latin:keyLabel="\@" />
-                </case>
-                <default>
-                    <Key
-                        latin:keyLabel="/"
-                        latin:keyHintLabel="\@"
-                        latin:moreKeys="\@"
-                        latin:keyStyle="hasShiftedLetterHintStyle" />
-                </default>
-            </switch>
-        </default>
-    </switch>
-</merge>
diff --git a/java/res/xml-sw768dp/row_dvorak4.xml b/java/res/xml-sw768dp/row_dvorak4.xml
index ebe517d..0827815 100644
--- a/java/res/xml-sw768dp/row_dvorak4.xml
+++ b/java/res/xml-sw768dp/row_dvorak4.xml
@@ -23,22 +23,24 @@
 >
     <Row
         latin:keyWidth="8.047%p"
+        latin:backgroundType="functional"
     >
         <include
+            latin:keyXPos="5.782%p"
             latin:keyboardLayout="@xml/key_settings" />
         <include
-            latin:keyXPos="13.829%p"
-            latin:keyboardLayout="@xml/keys_f1f2" />
+            latin:keyboardLayout="@xml/key_shortcut" />
+        <include
+            latin:keyboardLayout="@xml/key_f1" />
         <include
             latin:keyXPos="29.923%p"
-            latin:keyboardLayout="@xml/key_space" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
         <include
             latin:keyboardLayout="@xml/key_question_exclamation" />
         <include
             latin:keyboardLayout="@xml/key_dash" />
         <include
-            latin:keyXPos="-8.047%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_f2" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw768dp/row_hebrew4.xml b/java/res/xml-sw768dp/row_hebrew4.xml
index 477fd0d..180c564 100644
--- a/java/res/xml-sw768dp/row_hebrew4.xml
+++ b/java/res/xml-sw768dp/row_hebrew4.xml
@@ -23,20 +23,22 @@
 >
     <Row
         latin:keyWidth="8.047%p"
+        latin:backgroundType="functional"
     >
         <include
+            latin:keyXPos="5.782%p"
             latin:keyboardLayout="@xml/key_settings" />
         <include
-            latin:keyXPos="13.829%p"
-            latin:keyboardLayout="@xml/keys_f1f2" />
+            latin:keyboardLayout="@xml/key_shortcut" />
+        <include
+            latin:keyboardLayout="@xml/key_f1" />
         <include
             latin:keyXPos="29.923%p"
-            latin:keyboardLayout="@xml/key_space" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
         <include
             latin:keyboardLayout="@xml/keys_comma_period" />
         <include
-            latin:keyXPos="-8.047%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_f2" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw768dp/row_qwerty4.xml b/java/res/xml-sw768dp/row_qwerty4.xml
index 32a6476..92411f5 100644
--- a/java/res/xml-sw768dp/row_qwerty4.xml
+++ b/java/res/xml-sw768dp/row_qwerty4.xml
@@ -23,22 +23,24 @@
 >
     <Row
         latin:keyWidth="8.047%p"
+        latin:backgroundType="functional"
     >
         <include
+            latin:keyXPos="5.782%p"
             latin:keyboardLayout="@xml/key_settings" />
         <include
-            latin:keyXPos="13.829%p"
-            latin:keyboardLayout="@xml/keys_f1f2" />
+            latin:keyboardLayout="@xml/key_shortcut" />
+        <include
+            latin:keyboardLayout="@xml/key_f1" />
         <include
             latin:keyXPos="29.923%p"
-            latin:keyboardLayout="@xml/key_space" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
         <include
             latin:keyboardLayout="@xml/key_apostrophe" />
         <include
             latin:keyboardLayout="@xml/key_dash" />
         <include
-            latin:keyXPos="-8.047%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_f2" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw768dp/row_symbols4.xml b/java/res/xml-sw768dp/row_symbols4.xml
index bd85b40..4e1c119 100644
--- a/java/res/xml-sw768dp/row_symbols4.xml
+++ b/java/res/xml-sw768dp/row_symbols4.xml
@@ -23,25 +23,22 @@
 >
     <Row
         latin:keyWidth="8.047%p"
+        latin:backgroundType="functional"
     >
+        <Key
+            latin:keyXPos="13.829%p"
+            latin:keyLabel="/" />
         <include
-            latin:keyboardLayout="@xml/key_settings" />
-        <Key
-            latin:keyLabel="/"
-            latin:keyXPos="13.829%p" />
-        <Key
-            latin:keyLabel="\@" />
+            latin:keyboardLayout="@xml/key_f1" />
         <include
             latin:keyXPos="29.923%p"
-            latin:keyboardLayout="@xml/key_space" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
         <Key
             latin:keyLabel="&quot;"
             latin:moreKeys="!text/more_keys_for_tablet_double_quote" />
         <Key
             latin:keyLabel="_" />
-        <include
-            latin:keyXPos="-8.047%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+        <!-- Here is empty space. -->
     </Row>
 </merge>
diff --git a/java/res/xml-sw768dp/row_symbols_shift4.xml b/java/res/xml-sw768dp/row_symbols_shift4.xml
index 82c1d17..561351c 100644
--- a/java/res/xml-sw768dp/row_symbols_shift4.xml
+++ b/java/res/xml-sw768dp/row_symbols_shift4.xml
@@ -23,15 +23,13 @@
 >
     <Row
         latin:keyWidth="8.047%p"
+        latin:backgroundType="functional"
     >
-        <include
-            latin:keyboardLayout="@xml/key_settings" />
+        <!-- Here is empty space. -->
         <include
             latin:keyXPos="29.923%p"
-            latin:keyboardLayout="@xml/key_space" />
-        <include
-            latin:keyXPos="-8.047%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_space"
+            latin:backgroundType="normal" />
+        <!-- Here is empty space. -->
     </Row>
 </merge>
diff --git a/java/res/xml-sw768dp/rows_number_normal.xml b/java/res/xml-sw768dp/rows_number_normal.xml
index 42697ce..84910a8 100644
--- a/java/res/xml-sw768dp/rows_number_normal.xml
+++ b/java/res/xml-sw768dp/rows_number_normal.xml
@@ -30,15 +30,18 @@
             latin:keyLabel="-"
             latin:keyStyle="numKeyStyle"
             latin:keyXPos="13.829%p"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="+"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="."
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="1"
             latin:keyStyle="numKeyStyle"
@@ -60,11 +63,13 @@
             latin:keyWidth="13.829%p" />
         <Key
             latin:keyStyle="numStarKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="/"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <switch>
             <case
                 latin:mode="time|datetime"
@@ -74,13 +79,15 @@
                     latin:keyLabelFlags="hasPopupHint"
                     latin:moreKeys="!text/more_keys_for_am_pm"
                     latin:keyStyle="numKeyStyle"
-                    latin:keyWidth="8.047%p" />
+                    latin:keyWidth="8.047%p"
+                    latin:backgroundType="functional" />
             </case>
             <default>
                 <Key
                     latin:keyLabel=","
                     latin:keyStyle="numKeyStyle"
-                    latin:keyWidth="8.047%p" />
+                    latin:keyWidth="8.047%p"
+                    latin:backgroundType="functional" />
             </default>
         </switch>
         <Key
@@ -105,11 +112,13 @@
         <Key
             latin:keyLabel="("
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel=")"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <switch>
             <case
                 latin:mode="time|datetime"
@@ -117,13 +126,15 @@
                 <Key
                     latin:keyLabel=":"
                     latin:keyStyle="numKeyStyle"
-                    latin:keyWidth="8.047%p" />
+                    latin:keyWidth="8.047%p"
+                    latin:backgroundType="functional" />
             </case>
             <default>
                 <Key
                     latin:keyLabel="="
                     latin:keyStyle="numKeyStyle"
-                    latin:keyWidth="8.047%p" />
+                    latin:keyWidth="8.047%p"
+                    latin:backgroundType="functional" />
             </default>
         </switch>
         <Key
@@ -146,7 +157,8 @@
         <Key
             latin:keyStyle="spaceKeyStyle"
             latin:keyXPos="13.829%p"
-            latin:keyWidth="24.140%p" />
+            latin:keyWidth="24.140%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="numStarKeyStyle"
             latin:keyXPos="43.125%p" />
@@ -156,9 +168,5 @@
         <Key
             latin:keyLabel="#"
             latin:keyStyle="numKeyStyle" />
-        <include
-            latin:keyXPos="-8.047%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw768dp/rows_phone.xml b/java/res/xml-sw768dp/rows_phone.xml
index b3b3521..2f718db 100644
--- a/java/res/xml-sw768dp/rows_phone.xml
+++ b/java/res/xml-sw768dp/rows_phone.xml
@@ -34,14 +34,17 @@
             latin:keyLabel="-"
             latin:keyStyle="numKeyStyle"
             latin:keyXPos="13.829%p"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="+"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="numPauseKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="num1KeyStyle"
             latin:keyXPos="43.125%p" />
@@ -62,14 +65,17 @@
             latin:keyLabel=","
             latin:keyStyle="numKeyStyle"
             latin:keyXPos="13.829%p"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="."
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="numWaitKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="num4KeyStyle"
             latin:keyXPos="43.125%p" />
@@ -89,15 +95,18 @@
         <Key
             latin:keyLabel="("
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel=")"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyLabel="N"
             latin:keyStyle="numKeyStyle"
-            latin:keyWidth="8.047%p" />
+            latin:keyWidth="8.047%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="num7KeyStyle"
             latin:keyXPos="43.125%p" />
@@ -115,7 +124,8 @@
         <Key
             latin:keyStyle="spaceKeyStyle"
             latin:keyXPos="13.829%p"
-            latin:keyWidth="24.140%p" />
+            latin:keyWidth="24.140%p"
+            latin:backgroundType="functional" />
         <Key
             latin:keyStyle="numStarKeyStyle"
             latin:keyXPos="43.125%p" />
@@ -124,9 +134,5 @@
         <Key
             latin:keyLabel="#"
             latin:keyStyle="numKeyStyle" />
-        <include
-            latin:keyXPos="-8.047%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
-    </Row>
+   </Row>
 </merge>
diff --git a/java/res/xml/key_styles_common.xml b/java/res/xml/key_styles_common.xml
index 819cdc6..162119d 100644
--- a/java/res/xml/key_styles_common.xml
+++ b/java/res/xml/key_styles_common.xml
@@ -22,23 +22,8 @@
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
     <!-- Base key style for the key which may have settings or tab key as popup key. -->
-    <switch>
-        <case
-            latin:clobberSettingsKey="true"
-        >
-            <key-style
-                latin:styleName="f1MoreKeysStyle"
-                latin:backgroundType="functional" />
-        </case>
-        <!-- clobberSettingsKey="false" -->
-        <default>
-            <key-style
-                latin:styleName="f1MoreKeysStyle"
-                latin:keyLabelFlags="hasPopupHint"
-                latin:moreKeys="!text/settings_as_more_key"
-                latin:backgroundType="functional" />
-        </default>
-    </switch>
+    <include
+        latin:keyboardLayout="@xml/key_styles_f1" />
     <!-- Functional key styles -->
     <switch>
         <case
@@ -105,8 +90,7 @@
     <key-style
         latin:styleName="spaceKeyStyle"
         latin:code="!code/key_space"
-        latin:keyActionFlags="noKeyPreview|enableLongPress"
-        latin:backgroundType="functional" />
+        latin:keyActionFlags="noKeyPreview|enableLongPress" />
     <!-- U+200C: ZERO WIDTH NON-JOINER
          U+200D: ZERO WIDTH JOINER -->
     <key-style
@@ -115,8 +99,7 @@
         latin:keyIcon="!icon/zwnj_key"
         latin:moreKeys="!icon/zwj_key|&#x200D;"
         latin:keyLabelFlags="hasPopupHint"
-        latin:keyActionFlags="noKeyPreview"
-        latin:backgroundType="functional" />
+        latin:keyActionFlags="noKeyPreview" />
     <key-style
         latin:styleName="shortcutKeyStyle"
         latin:code="!code/key_shortcut"
@@ -137,8 +120,7 @@
         latin:code="!code/key_language_switch"
         latin:keyIcon="!icon/language_switch_key"
         latin:keyActionFlags="noKeyPreview|altCodeWhileTyping|enableLongPress"
-        latin:altCode="!code/key_space"
-        latin:backgroundType="functional" />
+        latin:altCode="!code/key_space" />
     <key-style
         latin:styleName="tabKeyStyle"
         latin:code="!code/key_tab"
diff --git a/java/res/xml/key_styles_f1.xml b/java/res/xml/key_styles_f1.xml
new file mode 100644
index 0000000..8dfc3cb
--- /dev/null
+++ b/java/res/xml/key_styles_f1.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, 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.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <!-- Base key style for the key which may have settings or tab key as popup key. -->
+    <!-- Kept as a separate file for cleaner overriding by an overlay.  -->
+    <switch>
+        <case
+            latin:clobberSettingsKey="true"
+        >
+            <key-style
+                latin:styleName="f1MoreKeysStyle"
+                latin:backgroundType="functional" />
+        </case>
+        <!-- clobberSettingsKey="false" -->
+        <default>
+            <key-style
+                latin:styleName="f1MoreKeysStyle"
+                latin:keyLabelFlags="hasPopupHint"
+                latin:moreKeys="!text/settings_as_more_key"
+                latin:backgroundType="functional" />
+        </default>
+    </switch>
+</merge>
diff --git a/java/res/xml/row_qwerty4.xml b/java/res/xml/row_qwerty4.xml
index ecb95e7..43385d2 100644
--- a/java/res/xml/row_qwerty4.xml
+++ b/java/res/xml/row_qwerty4.xml
@@ -38,15 +38,14 @@
             >
                 <!-- U+064B: "ً" ARABIC FATHATAN -->
                 <Key
-                    latin:keyLabel="."
                     latin:keyHintLabel="&#x064B;"
                     latin:keyLabelFlags="hasPopupHint|hasShiftedLetterHint"
                     latin:moreKeys="!text/more_keys_for_arabic_diacritics"
-                    latin:backgroundType="functional" />
+                    latin:keyStyle="punctuationKeyStyle" />
             </case>
             <default>
                 <Key
-                latin:keyStyle="punctuationKeyStyle" />
+                    latin:keyStyle="punctuationKeyStyle" />
             </default>
         </switch>
         <Key
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index ed873a7..e1e1ca9 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -227,7 +227,7 @@
         row.setXPos(keyXPos + keyWidth);
 
         mBackgroundType = style.getInt(keyAttr,
-                R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL);
+                R.styleable.Keyboard_Key_backgroundType, row.getDefaultBackgroundType());
 
         mVisualInsetsLeft = Math.round(Keyboard.Builder.getDimensionOrFraction(keyAttr,
                 R.styleable.Keyboard_Key_visualInsetsLeft, params.mBaseWidth, 0));
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 0be4cf3..6fc630d 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -89,7 +89,8 @@
     private static final int MINIMUM_LETTER_CODE = CODE_TAB;
 
     /** Special keys code. Must be negative.
-     * These should be aligned with values/keycodes.xml
+     * These should be aligned with KeyboardCodesSet.ID_TO_NAME[],
+     * KeyboardCodesSet.DEFAULT[] and KeyboardCodesSet.RTL[]
      */
     public static final int CODE_SHIFT = -1;
     public static final int CODE_SWITCH_ALPHA_SYMBOL = -2;
@@ -101,8 +102,9 @@
     public static final int CODE_ACTION_NEXT = -8;
     public static final int CODE_ACTION_PREVIOUS = -9;
     public static final int CODE_LANGUAGE_SWITCH = -10;
+    public static final int CODE_RESEARCH = -11;
     // Code value representing the code is not specified.
-    public static final int CODE_UNSPECIFIED = -11;
+    public static final int CODE_UNSPECIFIED = -12;
 
     public final KeyboardId mId;
     public final int mThemeId;
@@ -422,67 +424,67 @@
      * This class parses Keyboard XML file and eventually build a Keyboard.
      * The Keyboard XML file looks like:
      * <pre>
-     *   &gt;!-- xml/keyboard.xml --&lt;
-     *   &gt;Keyboard keyboard_attributes*&lt;
-     *     &gt;!-- Keyboard Content --&lt;
-     *     &gt;Row row_attributes*&lt;
-     *       &gt;!-- Row Content --&lt;
-     *       &gt;Key key_attributes* /&lt;
-     *       &gt;Spacer horizontalGap="32.0dp" /&lt;
-     *       &gt;include keyboardLayout="@xml/other_keys"&lt;
+     *   &lt;!-- xml/keyboard.xml --&gt;
+     *   &lt;Keyboard keyboard_attributes*&gt;
+     *     &lt;!-- Keyboard Content --&gt;
+     *     &lt;Row row_attributes*&gt;
+     *       &lt;!-- Row Content --&gt;
+     *       &lt;Key key_attributes* /&gt;
+     *       &lt;Spacer horizontalGap="32.0dp" /&gt;
+     *       &lt;include keyboardLayout="@xml/other_keys"&gt;
      *       ...
-     *     &gt;/Row&lt;
-     *     &gt;include keyboardLayout="@xml/other_rows"&lt;
+     *     &lt;/Row&gt;
+     *     &lt;include keyboardLayout="@xml/other_rows"&gt;
      *     ...
-     *   &gt;/Keyboard&lt;
+     *   &lt;/Keyboard&gt;
      * </pre>
-     * The XML file which is included in other file must have &gt;merge&lt; as root element,
+     * The XML file which is included in other file must have &lt;merge&gt; as root element,
      * such as:
      * <pre>
-     *   &gt;!-- xml/other_keys.xml --&lt;
-     *   &gt;merge&lt;
-     *     &gt;Key key_attributes* /&lt;
+     *   &lt;!-- xml/other_keys.xml --&gt;
+     *   &lt;merge&gt;
+     *     &lt;Key key_attributes* /&gt;
      *     ...
-     *   &gt;/merge&lt;
+     *   &lt;/merge&gt;
      * </pre>
      * and
      * <pre>
-     *   &gt;!-- xml/other_rows.xml --&lt;
-     *   &gt;merge&lt;
-     *     &gt;Row row_attributes*&lt;
-     *       &gt;Key key_attributes* /&lt;
-     *     &gt;/Row&lt;
+     *   &lt;!-- xml/other_rows.xml --&gt;
+     *   &lt;merge&gt;
+     *     &lt;Row row_attributes*&gt;
+     *       &lt;Key key_attributes* /&gt;
+     *     &lt;/Row&gt;
      *     ...
-     *   &gt;/merge&lt;
+     *   &lt;/merge&gt;
      * </pre>
      * You can also use switch-case-default tags to select Rows and Keys.
      * <pre>
-     *   &gt;switch&lt;
-     *     &gt;case case_attribute*&lt;
-     *       &gt;!-- Any valid tags at switch position --&lt;
-     *     &gt;/case&lt;
+     *   &lt;switch&gt;
+     *     &lt;case case_attribute*&gt;
+     *       &lt;!-- Any valid tags at switch position --&gt;
+     *     &lt;/case&gt;
      *     ...
-     *     &gt;default&lt;
-     *       &gt;!-- Any valid tags at switch position --&lt;
-     *     &gt;/default&lt;
-     *   &gt;/switch&lt;
+     *     &lt;default&gt;
+     *       &lt;!-- Any valid tags at switch position --&gt;
+     *     &lt;/default&gt;
+     *   &lt;/switch&gt;
      * </pre>
      * You can declare Key style and specify styles within Key tags.
      * <pre>
-     *     &gt;switch&lt;
-     *       &gt;case mode="email"&lt;
-     *         &gt;key-style styleName="f1-key" parentStyle="modifier-key"
+     *     &lt;switch&gt;
+     *       &lt;case mode="email"&gt;
+     *         &lt;key-style styleName="f1-key" parentStyle="modifier-key"
      *           keyLabel=".com"
-     *         /&lt;
-     *       &gt;/case&lt;
-     *       &gt;case mode="url"&lt;
-     *         &gt;key-style styleName="f1-key" parentStyle="modifier-key"
+     *         /&gt;
+     *       &lt;/case&gt;
+     *       &lt;case mode="url"&gt;
+     *         &lt;key-style styleName="f1-key" parentStyle="modifier-key"
      *           keyLabel="http://"
-     *         /&lt;
-     *       &gt;/case&lt;
-     *     &gt;/switch&lt;
+     *         /&gt;
+     *       &lt;/case&gt;
+     *     &lt;/switch&gt;
      *     ...
-     *     &gt;Key keyStyle="shift-key" ... /&lt;
+     *     &lt;Key keyStyle="shift-key" ... /&gt;
      * </pre>
      */
 
@@ -533,6 +535,8 @@
             public final int mRowHeight;
             /** Default keyLabelFlags in this row. */
             private int mDefaultKeyLabelFlags;
+            /** Default backgroundType for this row */
+            private int mDefaultBackgroundType;
 
             private final int mCurrentY;
             // Will be updated by {@link Key}'s constructor.
@@ -551,8 +555,11 @@
                 mDefaultKeyWidth = Builder.getDimensionOrFraction(keyAttr,
                         R.styleable.Keyboard_Key_keyWidth,
                         params.mBaseWidth, params.mDefaultKeyWidth);
+                mDefaultBackgroundType = keyAttr.getInt(R.styleable.Keyboard_Key_backgroundType,
+                        Key.BACKGROUND_TYPE_NORMAL);
                 keyAttr.recycle();
 
+                // TODO: Initialize this with <Row> attribute as backgroundType is done.
                 mDefaultKeyLabelFlags = 0;
                 mCurrentY = y;
                 mCurrentX = 0.0f;
@@ -574,6 +581,14 @@
                 mDefaultKeyLabelFlags = keyLabelFlags;
             }
 
+            public int getDefaultBackgroundType() {
+                return mDefaultBackgroundType;
+            }
+
+            public void setDefaultBackgroundType(int backgroundType) {
+                mDefaultBackgroundType = backgroundType;
+            }
+
             public void setXPos(float keyXPos) {
                 mCurrentX = keyXPos;
             }
@@ -952,6 +967,7 @@
                 int keyboardLayout = 0;
                 float savedDefaultKeyWidth = 0;
                 int savedDefaultKeyLabelFlags = 0;
+                int savedDefaultBackgroundType = Key.BACKGROUND_TYPE_NORMAL;
                 try {
                     XmlParseUtils.checkAttributeExists(keyboardAttr,
                             R.styleable.Keyboard_Include_keyboardLayout, "keyboardLayout",
@@ -959,22 +975,26 @@
                     keyboardLayout = keyboardAttr.getResourceId(
                             R.styleable.Keyboard_Include_keyboardLayout, 0);
                     if (row != null) {
-                        savedDefaultKeyWidth = row.getDefaultKeyWidth();
-                        savedDefaultKeyLabelFlags = row.getDefaultKeyLabelFlags();
                         if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyXPos)) {
                             // Override current x coordinate.
                             row.setXPos(row.getKeyX(keyAttr));
                         }
+                        // TODO: Remove this if-clause and do the same as backgroundType below.
+                        savedDefaultKeyWidth = row.getDefaultKeyWidth();
                         if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyWidth)) {
                             // Override default key width.
                             row.setDefaultKeyWidth(row.getKeyWidth(keyAttr));
                         }
-                        if (keyAttr.hasValue(R.styleable.Keyboard_Key_keyLabelFlags)) {
-                            // Override default key label flags.
-                            row.setDefaultKeyLabelFlags(
-                                    keyAttr.getInt(R.styleable.Keyboard_Key_keyLabelFlags, 0)
-                                    | savedDefaultKeyLabelFlags);
-                        }
+                        savedDefaultKeyLabelFlags = row.getDefaultKeyLabelFlags();
+                        // Bitwise-or default keyLabelFlag if exists.
+                        row.setDefaultKeyLabelFlags(keyAttr.getInt(
+                                R.styleable.Keyboard_Key_keyLabelFlags, 0)
+                                | savedDefaultKeyLabelFlags);
+                        savedDefaultBackgroundType = row.getDefaultBackgroundType();
+                        // Override default backgroundType if exists.
+                        row.setDefaultBackgroundType(keyAttr.getInt(
+                                R.styleable.Keyboard_Key_backgroundType,
+                                savedDefaultBackgroundType));
                     }
                 } finally {
                     keyboardAttr.recycle();
@@ -991,9 +1011,10 @@
                     parseMerge(parserForInclude, row, skip);
                 } finally {
                     if (row != null) {
-                        // Restore default key width and key label flags.
+                        // Restore default keyWidth, keyLabelFlags, and backgroundType.
                         row.setDefaultKeyWidth(savedDefaultKeyWidth);
                         row.setDefaultKeyLabelFlags(savedDefaultKeyLabelFlags);
+                        row.setDefaultBackgroundType(savedDefaultBackgroundType);
                     }
                     parserForInclude.close();
                 }
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java
index 67cb74f..f7981a3 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java
@@ -52,6 +52,7 @@
         "key_action_next",
         "key_action_previous",
         "key_language_switch",
+        "key_research",
         "key_unspecified",
         "key_left_parenthesis",
         "key_right_parenthesis",
@@ -86,6 +87,7 @@
         Keyboard.CODE_ACTION_NEXT,
         Keyboard.CODE_ACTION_PREVIOUS,
         Keyboard.CODE_LANGUAGE_SWITCH,
+        Keyboard.CODE_RESEARCH,
         Keyboard.CODE_UNSPECIFIED,
         CODE_LEFT_PARENTHESIS,
         CODE_RIGHT_PARENTHESIS,
@@ -112,6 +114,7 @@
         DEFAULT[11],
         DEFAULT[12],
         DEFAULT[13],
+        DEFAULT[14],
         CODE_RIGHT_PARENTHESIS,
         CODE_LEFT_PARENTHESIS,
         CODE_GREATER_THAN_SIGN,
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 77acf94..8e50af8 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -497,7 +497,7 @@
         // Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged()
         // is not guaranteed. It may even be called at the same time on a different thread.
         if (null == mPrefs) mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
-        mUserHistoryDictionary = new UserHistoryDictionary(
+        mUserHistoryDictionary = UserHistoryDictionary.getInstance(
                 this, localeStr, Suggest.DIC_USER_HISTORY, mPrefs);
         mSuggest.setUserHistoryDictionary(mUserHistoryDictionary);
     }
@@ -1345,6 +1345,11 @@
         case Keyboard.CODE_LANGUAGE_SWITCH:
             handleLanguageSwitchKey();
             break;
+        case Keyboard.CODE_RESEARCH:
+            if (ProductionFlag.IS_EXPERIMENTAL) {
+                ResearchLogger.getInstance().presentResearchDialog(this);
+            }
+            break;
         default:
             if (primaryCode == Keyboard.CODE_TAB
                     && mInputAttributes.mEditorAction == EditorInfo.IME_ACTION_NEXT) {
@@ -2459,10 +2464,10 @@
         final AlertDialog.Builder builder = new AlertDialog.Builder(this)
                 .setItems(items, listener)
                 .setTitle(title);
-        showOptionDialogInternal(builder.create());
+        showOptionDialog(builder.create());
     }
 
-    private void showOptionDialogInternal(AlertDialog dialog) {
+    /* package */ void showOptionDialog(AlertDialog dialog) {
         final IBinder windowToken = mKeyboardSwitcher.getKeyboardView().getWindowToken();
         if (windowToken == null) return;
 
diff --git a/java/src/com/android/inputmethod/latin/ResearchLogger.java b/java/src/com/android/inputmethod/latin/ResearchLogger.java
index 1628509..bb003f7 100644
--- a/java/src/com/android/inputmethod/latin/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/latin/ResearchLogger.java
@@ -18,6 +18,8 @@
 
 import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
 
+import android.app.AlertDialog;
+import android.content.DialogInterface;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.Editor;
 import android.inputmethodservice.InputMethodService;
@@ -33,9 +35,9 @@
 import android.view.inputmethod.CompletionInfo;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputConnection;
+import android.widget.Toast;
 
 import com.android.inputmethod.keyboard.Key;
-import com.android.inputmethod.keyboard.KeyDetector;
 import com.android.inputmethod.keyboard.Keyboard;
 import com.android.inputmethod.keyboard.KeyboardId;
 import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
@@ -134,12 +136,16 @@
         }
         if (prefs != null) {
             sIsLogging = prefs.getBoolean(PREF_USABILITY_STUDY_MODE, false);
-            prefs.registerOnSharedPreferenceChangeListener(sInstance);
+            prefs.registerOnSharedPreferenceChangeListener(this);
         }
     }
 
     public synchronized void start() {
         Log.d(TAG, "start called");
+        if (!sIsLogging) {
+            // Log.w(TAG, "not in usability mode; not logging");
+            return;
+        }
         if (mFilesDir == null || !mFilesDir.exists()) {
             Log.w(TAG, "IME storage directory does not exist.  Cannot start logging.");
         } else {
@@ -192,16 +198,17 @@
                         e1.printStackTrace();
                     } catch (IOException e) {
                         e.printStackTrace();
-                    }
-                    mJsonWriter = NULL_JSON_WRITER;
-                    mFile = null;
-                    mLoggingState = LOGGING_STATE_OFF;
-                    if (DEBUG) {
-                        Log.d(TAG, "logfile closed");
-                    }
-                    Log.d(TAG, "finished stop(), notifying");
-                    synchronized (ResearchLogger.this) {
-                        ResearchLogger.this.notify();
+                    } finally {
+                        mJsonWriter = NULL_JSON_WRITER;
+                        mFile = null;
+                        mLoggingState = LOGGING_STATE_OFF;
+                        if (DEBUG) {
+                            Log.d(TAG, "logfile closed");
+                        }
+                        Log.d(TAG, "finished stop(), notifying");
+                        synchronized (ResearchLogger.this) {
+                            ResearchLogger.this.notify();
+                        }
                     }
                 }
             });
@@ -213,6 +220,38 @@
         }
     }
 
+    public synchronized boolean abort() {
+        Log.d(TAG, "abort called");
+        boolean isLogFileDeleted = false;
+        if (mLoggingHandler != null && mLoggingState == LOGGING_STATE_ON) {
+            mLoggingState = LOGGING_STATE_STOPPING;
+            try {
+                Log.d(TAG, "closing jsonwriter");
+                mJsonWriter.endArray();
+                mJsonWriter.close();
+            } catch (IllegalStateException e1) {
+                // assume that this is just the json not being terminated properly.
+                // ignore
+                e1.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            } finally {
+                mJsonWriter = NULL_JSON_WRITER;
+                // delete file
+                final boolean isDeleted = mFile.delete();
+                if (isDeleted) {
+                    isLogFileDeleted = true;
+                }
+                mFile = null;
+                mLoggingState = LOGGING_STATE_OFF;
+                if (DEBUG) {
+                    Log.d(TAG, "logfile closed");
+                }
+            }
+        }
+        return isLogFileDeleted;
+    }
+
     /* package */ synchronized void flush() {
         try {
             mJsonWriter.flush();
@@ -227,6 +266,50 @@
             return;
         }
         sIsLogging = prefs.getBoolean(PREF_USABILITY_STUDY_MODE, false);
+        if (sIsLogging == false) {
+            abort();
+        }
+    }
+
+    /* package */ void presentResearchDialog(final LatinIME latinIME) {
+        final CharSequence title = latinIME.getString(R.string.english_ime_research_log);
+        final CharSequence[] items = new CharSequence[] {
+                latinIME.getString(R.string.note_timestamp_for_researchlog),
+                latinIME.getString(R.string.do_not_log_this_session),
+        };
+        final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface di, int position) {
+                di.dismiss();
+                switch (position) {
+                    case 0:
+                        ResearchLogger.getInstance().userTimestamp();
+                        Toast.makeText(latinIME, R.string.notify_recorded_timestamp,
+                                Toast.LENGTH_LONG).show();
+                        break;
+                    case 1:
+                        Toast toast = Toast.makeText(latinIME,
+                                R.string.notify_session_log_deleting, Toast.LENGTH_LONG);
+                        toast.show();
+                        final ResearchLogger logger = ResearchLogger.getInstance();
+                        boolean isLogDeleted = logger.abort();
+                        toast.cancel();
+                        if (isLogDeleted) {
+                            Toast.makeText(latinIME, R.string.notify_session_log_deleted,
+                                    Toast.LENGTH_LONG).show();
+                        } else {
+                            Toast.makeText(latinIME,
+                                    R.string.notify_session_log_not_deleted, Toast.LENGTH_LONG)
+                                    .show();
+                        }
+                        break;
+                }
+            }
+        };
+        final AlertDialog.Builder builder = new AlertDialog.Builder(latinIME)
+                .setItems(items, listener)
+                .setTitle(title);
+        latinIME.showOptionDialog(builder.create());
     }
 
     private static final String CURRENT_TIME_KEY = "_ct";
@@ -756,4 +839,11 @@
             getInstance().writeEvent(EVENTKEYS_SUGGESTIONSVIEW_SETSUGGESTIONS, values);
         }
     }
+
+    private static final String[] EVENTKEYS_USER_TIMESTAMP = {
+        "UserTimestamp"
+    };
+    public void userTimestamp() {
+        getInstance().writeEvent(EVENTKEYS_USER_TIMESTAMP, EVENTKEYS_NULLVALUES);
+    }
 }
diff --git a/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java b/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java
index a6ff895..a73e71b 100644
--- a/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java
@@ -29,7 +29,9 @@
 
 import com.android.inputmethod.latin.UserHistoryForgettingCurveUtils.ForgettingCurveParams;
 
+import java.lang.ref.SoftReference;
 import java.util.HashMap;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * Locally gathers stats about the words user types and various other signals like auto-correction
@@ -38,6 +40,7 @@
 public class UserHistoryDictionary extends ExpandableDictionary {
     private static final String TAG = "UserHistoryDictionary";
     public static final boolean DBG_SAVE_RESTORE = false;
+    public static final boolean PROFILE_SAVE_RESTORE = LatinImeLogger.sDBG;
 
     /** Any pair being typed or picked */
     private static final int FREQUENCY_FOR_TYPED = 2;
@@ -77,13 +80,14 @@
     /** Locale for which this user history dictionary is storing words */
     private final String mLocale;
 
-    private UserHistoryDictionaryBigramList mBigramList =
+    private final UserHistoryDictionaryBigramList mBigramList =
             new UserHistoryDictionaryBigramList();
-    private final Object mPendingWritesLock = new Object();
     private static volatile boolean sUpdatingDB = false;
     private final SharedPreferences mPrefs;
 
     private final static HashMap<String, String> sDictProjectionMap;
+    private final static ConcurrentHashMap<String, SoftReference<UserHistoryDictionary>>
+            sLangDictCache = new ConcurrentHashMap<String, SoftReference<UserHistoryDictionary>>();
 
     static {
         sDictProjectionMap = new HashMap<String, String>();
@@ -107,7 +111,26 @@
         sDeleteHistoryBigrams = deleteHistoryBigram;
     }
 
-    public UserHistoryDictionary(final Context context, final String locale, final int dicTypeId,
+    public synchronized static UserHistoryDictionary getInstance(
+            final Context context, final String locale,
+            final int dictTypeId, final SharedPreferences sp) {
+        if (sLangDictCache.containsKey(locale)) {
+            final SoftReference<UserHistoryDictionary> ref = sLangDictCache.get(locale);
+            final UserHistoryDictionary dict = ref == null ? null : ref.get();
+            if (dict != null) {
+                if (PROFILE_SAVE_RESTORE) {
+                    Log.w(TAG, "Use cached UserHistoryDictionary for " + locale);
+                }
+                return dict;
+            }
+        }
+        final UserHistoryDictionary dict =
+                new UserHistoryDictionary(context, locale, dictTypeId, sp);
+        sLangDictCache.put(locale, new SoftReference<UserHistoryDictionary>(dict));
+        return dict;
+    }
+
+    private UserHistoryDictionary(final Context context, final String locale, final int dicTypeId,
             SharedPreferences sp) {
         super(context, dicTypeId);
         mLocale = locale;
@@ -123,12 +146,13 @@
     @Override
     public void close() {
         flushPendingWrites();
-        SettingsValues.setLastUserHistoryWriteTime(mPrefs, mLocale);
         // Don't close the database as locale changes will require it to be reopened anyway
         // Also, the database is written to somewhat frequently, so it needs to be kept alive
         // throughout the life of the process.
         // mOpenHelper.close();
-        super.close();
+        // Ignore close because we cache UserHistoryDictionary for each language. See getInstance()
+        // above.
+        // super.close();
     }
 
     /**
@@ -160,7 +184,7 @@
         } else {
             freq = super.setBigramAndGetFrequency(word1, word2, new ForgettingCurveParams(isValid));
         }
-        synchronized (mPendingWritesLock) {
+        synchronized (mBigramList) {
             mBigramList.addBigram(word1, word2);
         }
 
@@ -168,7 +192,7 @@
     }
 
     public boolean cancelAddingUserHistory(String word1, String word2) {
-        synchronized (mPendingWritesLock) {
+        synchronized (mBigramList) {
             if (mBigramList.removeBigram(word1, word2)) {
                 return super.removeBigram(word1, word2);
             }
@@ -180,19 +204,17 @@
      * Schedules a background thread to write any pending words to the database.
      */
     private void flushPendingWrites() {
-        synchronized (mPendingWritesLock) {
+        synchronized (mBigramList) {
             // Nothing pending? Return
             if (mBigramList.isEmpty()) return;
             // Create a background thread to write the pending entries
-            new UpdateDbTask(sOpenHelper, mBigramList, mLocale, this).execute();
-            // Create a new map for writing new entries into while the old one is written to db
-            mBigramList = new UserHistoryDictionaryBigramList();
+            new UpdateDbTask(sOpenHelper, mBigramList, mLocale, this, mPrefs).execute();
         }
     }
 
     /** Used for testing purpose **/
     void waitUntilUpdateDBDone() {
-        synchronized (mPendingWritesLock) {
+        synchronized (mBigramList) {
             while (sUpdatingDB) {
                 try {
                     Thread.sleep(100);
@@ -205,41 +227,46 @@
 
     @Override
     public void loadDictionaryAsync() {
-        final long last = SettingsValues.getLastUserHistoryWriteTime(mPrefs, mLocale);
-        final long now = System.currentTimeMillis();
-        // Load the words that correspond to the current input locale
-        final Cursor cursor = query(MAIN_COLUMN_LOCALE + "=?", new String[] { mLocale });
-        if (null == cursor) return;
-        try {
-            if (cursor.moveToFirst()) {
-                final int word1Index = cursor.getColumnIndex(MAIN_COLUMN_WORD1);
-                final int word2Index = cursor.getColumnIndex(MAIN_COLUMN_WORD2);
-                final int fcIndex = cursor.getColumnIndex(COLUMN_FORGETTING_CURVE_VALUE);
-                while (!cursor.isAfterLast()) {
-                    final String word1 = cursor.getString(word1Index);
-                    final String word2 = cursor.getString(word2Index);
-                    final int fc = cursor.getInt(fcIndex);
-                    if (DBG_SAVE_RESTORE) {
-                        Log.d(TAG, "--- Load user history: " + word1 + ", " + word2 + ","
-                                + mLocale + "," + this);
-                    }
-                    // Safeguard against adding really long words. Stack may overflow due
-                    // to recursive lookup
-                    if (null == word1) {
-                        super.addWord(word2, null /* shortcut */, fc);
-                    } else if (word1.length() < BinaryDictionary.MAX_WORD_LENGTH
-                            && word2.length() < BinaryDictionary.MAX_WORD_LENGTH) {
-                        super.setBigramAndGetFrequency(
-                                word1, word2, new ForgettingCurveParams(fc, now, last));
-                    }
-                    synchronized(mPendingWritesLock) {
+        synchronized(mBigramList) {
+            final long last = SettingsValues.getLastUserHistoryWriteTime(mPrefs, mLocale);
+            final long now = System.currentTimeMillis();
+            // Load the words that correspond to the current input locale
+            final Cursor cursor = query(MAIN_COLUMN_LOCALE + "=?", new String[] { mLocale });
+            if (null == cursor) return;
+            try {
+                if (cursor.moveToFirst()) {
+                    final int word1Index = cursor.getColumnIndex(MAIN_COLUMN_WORD1);
+                    final int word2Index = cursor.getColumnIndex(MAIN_COLUMN_WORD2);
+                    final int fcIndex = cursor.getColumnIndex(COLUMN_FORGETTING_CURVE_VALUE);
+                    while (!cursor.isAfterLast()) {
+                        final String word1 = cursor.getString(word1Index);
+                        final String word2 = cursor.getString(word2Index);
+                        final int fc = cursor.getInt(fcIndex);
+                        if (DBG_SAVE_RESTORE) {
+                            Log.d(TAG, "--- Load user history: " + word1 + ", " + word2 + ","
+                                    + mLocale + "," + this);
+                        }
+                        // Safeguard against adding really long words. Stack may overflow due
+                        // to recursive lookup
+                        if (null == word1) {
+                            super.addWord(word2, null /* shortcut */, fc);
+                        } else if (word1.length() < BinaryDictionary.MAX_WORD_LENGTH
+                                && word2.length() < BinaryDictionary.MAX_WORD_LENGTH) {
+                            super.setBigramAndGetFrequency(
+                                    word1, word2, new ForgettingCurveParams(fc, now, last));
+                        }
                         mBigramList.addBigram(word1, word2, (byte)fc);
+                        cursor.moveToNext();
                     }
-                    cursor.moveToNext();
+                }
+            } finally {
+                cursor.close();
+                if (PROFILE_SAVE_RESTORE) {
+                    final long diff = System.currentTimeMillis() - now;
+                    Log.w(TAG, "PROF: Load User HistoryDictionary: "
+                            + mLocale + ", " + diff + "ms.");
                 }
             }
-        } finally {
-            cursor.close();
         }
     }
 
@@ -317,14 +344,16 @@
         private final DatabaseHelper mDbHelper;
         private final String mLocale;
         private final UserHistoryDictionary mUserHistoryDictionary;
+        private final SharedPreferences mPrefs;
 
         public UpdateDbTask(
                 DatabaseHelper openHelper, UserHistoryDictionaryBigramList pendingWrites,
-                String locale, UserHistoryDictionary dict) {
+                String locale, UserHistoryDictionary dict, SharedPreferences prefs) {
             mBigramList = pendingWrites;
             mLocale = locale;
             mDbHelper = openHelper;
             mUserHistoryDictionary = dict;
+            mPrefs = prefs;
         }
 
         /** Prune any old data if the database is getting too big. */
@@ -363,37 +392,39 @@
 
         @Override
         protected Void doInBackground(Void... v) {
-            SQLiteDatabase db = null;
-            try {
-                db = mDbHelper.getWritableDatabase();
-            } catch (android.database.sqlite.SQLiteCantOpenDatabaseException e) {
-                // If we can't open the db, don't do anything. Exit through the next test
-                // for non-nullity of the db variable.
-            }
-            if (null == db) {
-                // Not much we can do. Just exit.
-                sUpdatingDB = false;
-                return null;
-            }
-            db.execSQL("PRAGMA foreign_keys = ON;");
-            final boolean addLevel0Bigram = mBigramList.size() <= sMaxHistoryBigrams;
+            synchronized(mBigramList) {
+                final long now = PROFILE_SAVE_RESTORE ? System.currentTimeMillis() : 0;
+                int profTotal = 0;
+                int profInsert = 0;
+                int profDelete = 0;
+                SQLiteDatabase db = null;
+                try {
+                    db = mDbHelper.getWritableDatabase();
+                } catch (android.database.sqlite.SQLiteCantOpenDatabaseException e) {
+                    // If we can't open the db, don't do anything. Exit through the next test
+                    // for non-nullity of the db variable.
+                }
+                if (null == db) {
+                    // Not much we can do. Just exit.
+                    sUpdatingDB = false;
+                    return null;
+                }
+                db.execSQL("PRAGMA foreign_keys = ON;");
+                final boolean addLevel0Bigram = mBigramList.size() <= sMaxHistoryBigrams;
 
-            // Write all the entries to the db
-            for (String word1 : mBigramList.keySet()) {
-                final HashMap<String, Byte> word1Bigrams = mBigramList.getBigrams(word1);
-                for (String word2 : word1Bigrams.keySet()) {
-                    // Get new frequency. Do not insert shortcuts/bigrams which freq is "-1".
-                    final int freq; // -1, or 0~255
-                    if (word1 == null) {
-                        freq = FREQUENCY_FOR_TYPED;
-                    } else {
-                        final NextWord nw = mUserHistoryDictionary.getBigramWord(word1, word2);
-                        if (nw != null) {
-                            final ForgettingCurveParams fcp = nw.getFcParams();
+                // Write all the entries to the db
+                for (String word1 : mBigramList.keySet()) {
+                    final HashMap<String, Byte> word1Bigrams = mBigramList.getBigrams(word1);
+                    for (String word2 : word1Bigrams.keySet()) {
+                        if (PROFILE_SAVE_RESTORE) {
+                            ++profTotal;
+                        }
+                        // Get new frequency. Do not insert unigrams/bigrams which freq is "-1".
+                        final int freq; // -1, or 0~255
+                        if (word1 == null) { // unigram
+                            freq = FREQUENCY_FOR_TYPED;
                             final byte prevFc = word1Bigrams.get(word2);
-                            final byte fc = (byte)fcp.getFc();
-                            final boolean isValid = fcp.isValid();
-                            if (prevFc > 0 && prevFc == fc) {
+                            if (prevFc == FREQUENCY_FOR_TYPED) {
                                 // No need to update since we found no changes for this entry.
                                 // Just skip to the next entry.
                                 if (DBG_SAVE_RESTORE) {
@@ -401,67 +432,100 @@
                                             + "," + prevFc);
                                 }
                                 continue;
-                            } else if (UserHistoryForgettingCurveUtils.
-                                    needsToSave(fc, isValid, addLevel0Bigram)) {
-                                freq = fc;
+                            }
+                        } else { // bigram
+                            final NextWord nw = mUserHistoryDictionary.getBigramWord(word1, word2);
+                            if (nw != null) {
+                                final ForgettingCurveParams fcp = nw.getFcParams();
+                                final byte prevFc = word1Bigrams.get(word2);
+                                final byte fc = (byte)fcp.getFc();
+                                final boolean isValid = fcp.isValid();
+                                if (prevFc > 0 && prevFc == fc) {
+                                    // No need to update since we found no changes for this entry.
+                                    // Just skip to the next entry.
+                                    if (DBG_SAVE_RESTORE) {
+                                        Log.d(TAG, "Skip update user history: " + word1 + ","
+                                                + word2 + "," + prevFc);
+                                    }
+                                    continue;
+                                } else if (UserHistoryForgettingCurveUtils.
+                                        needsToSave(fc, isValid, addLevel0Bigram)) {
+                                    freq = fc;
+                                } else {
+                                    freq = -1;
+                                }
                             } else {
                                 freq = -1;
                             }
-                        } else {
-                            freq = -1;
                         }
-                    }
-                    // TODO: this process of making a text search for each pair each time
-                    // is terribly inefficient. Optimize this.
-                    // Find pair id
-                    Cursor c = null;
-                    try {
-                        if (null != word1) {
-                            c = db.query(MAIN_TABLE_NAME, new String[] { MAIN_COLUMN_ID },
-                                    MAIN_COLUMN_WORD1 + "=? AND " + MAIN_COLUMN_WORD2 + "=? AND "
-                                            + MAIN_COLUMN_LOCALE + "=?",
-                                            new String[] { word1, word2, mLocale }, null, null,
-                                            null);
-                        } else {
-                            c = db.query(MAIN_TABLE_NAME, new String[] { MAIN_COLUMN_ID },
-                                    MAIN_COLUMN_WORD1 + " IS NULL AND " + MAIN_COLUMN_WORD2
-                                            + "=? AND " + MAIN_COLUMN_LOCALE + "=?",
-                                            new String[] { word2, mLocale }, null, null, null);
-                        }
-
-                        final int pairId;
-                        if (c.moveToFirst()) {
-                            // Delete existing pair
-                            pairId = c.getInt(c.getColumnIndex(MAIN_COLUMN_ID));
-                            db.delete(FREQ_TABLE_NAME, FREQ_COLUMN_PAIR_ID + "=?",
-                                    new String[] { Integer.toString(pairId) });
-                        } else {
-                            // Create new pair
-                            Long pairIdLong = db.insert(MAIN_TABLE_NAME, null,
-                                    getContentValues(word1, word2, mLocale));
-                            pairId = pairIdLong.intValue();
-                        }
-                        if (freq > 0) {
-                            if (DBG_SAVE_RESTORE) {
-                                Log.d(TAG, "--- Save user history: " + word1 + ", " + word2
-                                        + mLocale + "," + this);
+                        // TODO: this process of making a text search for each pair each time
+                        // is terribly inefficient. Optimize this.
+                        // Find pair id
+                        Cursor c = null;
+                        try {
+                            if (null != word1) {
+                                c = db.query(MAIN_TABLE_NAME, new String[] { MAIN_COLUMN_ID },
+                                        MAIN_COLUMN_WORD1 + "=? AND " + MAIN_COLUMN_WORD2 + "=? AND "
+                                                + MAIN_COLUMN_LOCALE + "=?",
+                                                new String[] { word1, word2, mLocale }, null, null,
+                                                null);
+                            } else {
+                                c = db.query(MAIN_TABLE_NAME, new String[] { MAIN_COLUMN_ID },
+                                        MAIN_COLUMN_WORD1 + " IS NULL AND " + MAIN_COLUMN_WORD2
+                                                + "=? AND " + MAIN_COLUMN_LOCALE + "=?",
+                                                new String[] { word2, mLocale }, null, null, null);
                             }
-                            // Insert new frequency
-                            db.insert(FREQ_TABLE_NAME, null,
-                                    getFrequencyContentValues(pairId, freq));
-                        }
-                    } finally {
-                        if (c != null) {
-                            c.close();
+
+                            final int pairId;
+                            if (c.moveToFirst()) {
+                                if (PROFILE_SAVE_RESTORE) {
+                                    ++profDelete;
+                                }
+                                // Delete existing pair
+                                pairId = c.getInt(c.getColumnIndex(MAIN_COLUMN_ID));
+                                db.delete(FREQ_TABLE_NAME, FREQ_COLUMN_PAIR_ID + "=?",
+                                        new String[] { Integer.toString(pairId) });
+                            } else {
+                                // Create new pair
+                                Long pairIdLong = db.insert(MAIN_TABLE_NAME, null,
+                                        getContentValues(word1, word2, mLocale));
+                                pairId = pairIdLong.intValue();
+                            }
+                            if (freq > 0) {
+                                if (PROFILE_SAVE_RESTORE) {
+                                    ++profInsert;
+                                }
+                                if (DBG_SAVE_RESTORE) {
+                                    Log.d(TAG, "--- Save user history: " + word1 + ", " + word2
+                                            + mLocale + "," + this);
+                                }
+                                // Insert new frequency
+                                db.insert(FREQ_TABLE_NAME, null,
+                                        getFrequencyContentValues(pairId, freq));
+                                // Update an existing bigram entry in mBigramList too in order to
+                                // synchronize the SQL DB and mBigramList.
+                                mBigramList.updateBigram(word1, word2, (byte)freq);
+                            }
+                        } finally {
+                            if (c != null) {
+                                c.close();
+                            }
                         }
                     }
                 }
-            }
 
-            checkPruneData(db);
-            sUpdatingDB = false;
-
-            return null;
+                checkPruneData(db);
+                // Save the timestamp after we finish writing the SQL DB.
+                SettingsValues.setLastUserHistoryWriteTime(mPrefs, mLocale);
+                sUpdatingDB = false;
+                if (PROFILE_SAVE_RESTORE) {
+                    final long diff = System.currentTimeMillis() - now;
+                    Log.w(TAG, "PROF: Write User HistoryDictionary: " + mLocale + ", "+ diff
+                            + "ms. Total: " + profTotal + ". Insert: " + profInsert + ". Delete: "
+                            + profDelete);
+                }
+                return null;
+            } // synchronized
         }
 
         private static ContentValues getContentValues(String word1, String word2, String locale) {
diff --git a/java/src/com/android/inputmethod/latin/UserHistoryDictionaryBigramList.java b/java/src/com/android/inputmethod/latin/UserHistoryDictionaryBigramList.java
index 96400dd..2884774 100644
--- a/java/src/com/android/inputmethod/latin/UserHistoryDictionaryBigramList.java
+++ b/java/src/com/android/inputmethod/latin/UserHistoryDictionaryBigramList.java
@@ -39,13 +39,19 @@
         mBigramMap.clear();
     }
 
+    /**
+     * Called when the user typed a word.
+     */
     public void addBigram(String word1, String word2) {
         addBigram(word1, word2, FORGETTING_CURVE_INITIAL_VALUE);
     }
 
+    /**
+     * Called when loaded from the SQL DB.
+     */
     public void addBigram(String word1, String word2, byte fcValue) {
         if (UserHistoryDictionary.DBG_SAVE_RESTORE) {
-            Log.d(TAG, "--- add bigram: " + word1 + ", " + word2);
+            Log.d(TAG, "--- add bigram: " + word1 + ", " + word2 + ", " + fcValue);
         }
         final HashMap<String, Byte> map;
         if (mBigramMap.containsKey(word1)) {
@@ -60,6 +66,25 @@
         }
     }
 
+    /**
+     * Called when inserted to the SQL DB.
+     */
+    public void updateBigram(String word1, String word2, byte fcValue) {
+        if (UserHistoryDictionary.DBG_SAVE_RESTORE) {
+            Log.d(TAG, "--- update bigram: " + word1 + ", " + word2 + ", " + fcValue);
+        }
+        final HashMap<String, Byte> map;
+        if (mBigramMap.containsKey(word1)) {
+            map = mBigramMap.get(word1);
+        } else {
+            return;
+        }
+        if (!map.containsKey(word2)) {
+            return;
+        }
+        map.put(word2, fcValue);
+    }
+
     public int size() {
         return mSize;
     }
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 8128779..d34cad2 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -372,27 +372,32 @@
         mUserDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
         final Map<String, Dictionary> oldWhitelistDictionaries = mWhitelistDictionaries;
         mWhitelistDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
-        for (DictionaryPool pool : oldPools.values()) {
-            pool.close();
-        }
-        for (Dictionary dict : oldUserDictionaries.values()) {
-            dict.close();
-        }
-        for (Dictionary dict : oldWhitelistDictionaries.values()) {
-            dict.close();
-        }
-        synchronized (mUseContactsLock) {
-            if (null != mContactsDictionary) {
-                // The synchronously loaded contacts dictionary should have been in one
-                // or several pools, but it is shielded against multiple closing and it's
-                // safe to call it several times.
-                final Dictionary dictToClose = mContactsDictionary;
-                // TODO: revert to the concrete type when USE_BINARY_CONTACTS_DICTIONARY is no
-                // longer needed
-                mContactsDictionary = null;
-                dictToClose.close();
+        new Thread("spellchecker_close_dicts") {
+            @Override
+            public void run() {
+                for (DictionaryPool pool : oldPools.values()) {
+                    pool.close();
+                }
+                for (Dictionary dict : oldUserDictionaries.values()) {
+                    dict.close();
+                }
+                for (Dictionary dict : oldWhitelistDictionaries.values()) {
+                    dict.close();
+                }
+                synchronized (mUseContactsLock) {
+                    if (null != mContactsDictionary) {
+                        // The synchronously loaded contacts dictionary should have been in one
+                        // or several pools, but it is shielded against multiple closing and it's
+                        // safe to call it several times.
+                        final Dictionary dictToClose = mContactsDictionary;
+                        // TODO: revert to the concrete type when USE_BINARY_CONTACTS_DICTIONARY
+                        // is no longer needed
+                        mContactsDictionary = null;
+                        dictToClose.close();
+                    }
+                }
             }
-        }
+        }.start();
     }
 
     private DictionaryPool getDictionaryPool(final String locale) {
@@ -496,20 +501,32 @@
         }
 
         private static class SuggestionsCache {
+            private static final char CHAR_DELIMITER = '\uFFFC';
             private static final int MAX_CACHE_SIZE = 50;
-            // TODO: support bigram
             private final LruCache<String, SuggestionsParams> mUnigramSuggestionsInfoCache =
                     new LruCache<String, SuggestionsParams>(MAX_CACHE_SIZE);
 
-            public SuggestionsParams getSuggestionsFromCache(String query) {
-                return mUnigramSuggestionsInfoCache.get(query);
+            // TODO: Support n-gram input
+            private static String generateKey(String query, String prevWord) {
+                if (TextUtils.isEmpty(query) || TextUtils.isEmpty(prevWord)) {
+                    return query;
+                }
+                return query + CHAR_DELIMITER + prevWord;
             }
 
-            public void putSuggestionsToCache(String query, String[] suggestions, int flags) {
+            // TODO: Support n-gram input
+            public SuggestionsParams getSuggestionsFromCache(String query, String prevWord) {
+                return mUnigramSuggestionsInfoCache.get(generateKey(query, prevWord));
+            }
+
+            // TODO: Support n-gram input
+            public void putSuggestionsToCache(
+                    String query, String prevWord, String[] suggestions, int flags) {
                 if (suggestions == null || TextUtils.isEmpty(query)) {
                     return;
                 }
-                mUnigramSuggestionsInfoCache.put(query, new SuggestionsParams(suggestions, flags));
+                mUnigramSuggestionsInfoCache.put(
+                        generateKey(query, prevWord), new SuggestionsParams(suggestions, flags));
             }
         }
 
@@ -604,6 +621,7 @@
             final ArrayList<Integer> additionalLengths = new ArrayList<Integer>();
             final ArrayList<SuggestionsInfo> additionalSuggestionsInfos =
                     new ArrayList<SuggestionsInfo>();
+            String currentWord = null;
             for (int i = 0; i < N; ++i) {
                 final SuggestionsInfo si = ssi.getSuggestionsInfoAt(i);
                 final int flags = si.getSuggestionsAttributes();
@@ -613,6 +631,8 @@
                 final int offset = ssi.getOffsetAt(i);
                 final int length = ssi.getLengthAt(i);
                 final String subText = typedText.substring(offset, offset + length);
+                final String prevWord = currentWord;
+                currentWord = subText;
                 if (!subText.contains(SINGLE_QUOTE)) {
                     continue;
                 }
@@ -626,7 +646,8 @@
                     if (TextUtils.isEmpty(splitText)) {
                         continue;
                     }
-                    if (mSuggestionsCache.getSuggestionsFromCache(splitText) == null) {
+                    if (mSuggestionsCache.getSuggestionsFromCache(
+                            splitText, prevWord) == null) {
                         continue;
                     }
                     final int newLength = splitText.length();
@@ -722,7 +743,7 @@
             try {
                 final String inText = textInfo.getText();
                 final SuggestionsParams cachedSuggestionsParams =
-                        mSuggestionsCache.getSuggestionsFromCache(inText);
+                        mSuggestionsCache.getSuggestionsFromCache(inText, prevWord);
                 if (cachedSuggestionsParams != null) {
                     if (DBG) {
                         Log.d(TAG, "Cache hit: " + inText + ", " + cachedSuggestionsParams.mFlags);
@@ -814,7 +835,7 @@
                                         .getValueOf_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS()
                                 : 0);
                 final SuggestionsInfo retval = new SuggestionsInfo(flags, result.mSuggestions);
-                mSuggestionsCache.putSuggestionsToCache(text, result.mSuggestions, flags);
+                mSuggestionsCache.putSuggestionsToCache(text, prevWord, result.mSuggestions, flags);
                 return retval;
             } catch (RuntimeException e) {
                 // Don't kill the keyboard if there is a bug in the spell checker