diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index abd1dc6..1f4909f 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -28,6 +28,7 @@
 import com.android.inputmethod.compat.VibratorCompatWrapper;
 import com.android.inputmethod.keyboard.internal.KeySpecParser;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
@@ -174,28 +175,34 @@
     }
 
     private static SuggestedWords createSuggestPuncList(final String[] puncs) {
-        final SuggestedWords.Builder builder = new SuggestedWords.Builder();
+        final ArrayList<CharSequence> puncList = new ArrayList<CharSequence>();
         if (puncs != null) {
             for (final String puncSpec : puncs) {
-                builder.addWord(KeySpecParser.getLabel(puncSpec));
+                puncList.add(KeySpecParser.getLabel(puncSpec));
             }
         }
-        return builder.setIsPunctuationSuggestions().build();
+        final SuggestedWords.Builder builder = new SuggestedWords.Builder()
+                .addWords(puncList, null)
+                .setIsPunctuationSuggestions();
+        return builder.build();
     }
 
     private static SuggestedWords createSuggestPuncOutputTextList(final String[] puncs) {
-        final SuggestedWords.Builder builder = new SuggestedWords.Builder();
+        final ArrayList<CharSequence> puncOutputTextList = new ArrayList<CharSequence>();
         if (puncs != null) {
             for (final String puncSpec : puncs) {
                 final String outputText = KeySpecParser.getOutputText(puncSpec);
                 if (outputText != null) {
-                    builder.addWord(outputText);
+                    puncOutputTextList.add(outputText);
                 } else {
-                    builder.addWord(KeySpecParser.getLabel(puncSpec));
+                    puncOutputTextList.add(KeySpecParser.getLabel(puncSpec));
                 }
             }
         }
-        return builder.setIsPunctuationSuggestions().build();
+        final SuggestedWords.Builder builder = new SuggestedWords.Builder()
+                .addWords(puncOutputTextList, null)
+                .setIsPunctuationSuggestions();
+        return builder.build();
     }
 
     private static String createWordSeparators(final String weakSpaceStrippers,
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 4a51e79..9959292 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -104,17 +104,6 @@
             return this;
         }
 
-        public Builder addWord(CharSequence word) {
-            return addWord(word, null, false);
-        }
-
-        public Builder addWord(CharSequence word, CharSequence debugString,
-                boolean isPreviousSuggestedWord) {
-            SuggestedWordInfo info = new SuggestedWordInfo(word, debugString,
-                    isPreviousSuggestedWord);
-            return addWord(word, info);
-        }
-
         /* package for tests */
         Builder addWord(CharSequence word, SuggestedWordInfo suggestedWordInfo) {
             if (!TextUtils.isEmpty(suggestedWordInfo.mWord)) {
@@ -169,14 +158,14 @@
                 SuggestedWords previousSuggestions) {
             mSuggestedWordInfoList.clear();
             final HashSet<String> alreadySeen = new HashSet<String>();
-            addWord(typedWord, null, false);
+            addWord(typedWord, new SuggestedWordInfo(typedWord, null, false));
             alreadySeen.add(typedWord.toString());
             final int previousSize = previousSuggestions.size();
             for (int pos = 1; pos < previousSize; pos++) {
                 final String prevWord = previousSuggestions.getWord(pos).toString();
                 // Filter out duplicate suggestion.
                 if (!alreadySeen.contains(prevWord)) {
-                    addWord(prevWord, null, true);
+                    addWord(prevWord, new SuggestedWordInfo(prevWord, null, true));
                     alreadySeen.add(prevWord);
                 }
             }
