diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
index bf5f20158af215d20d67ce81d61aed770f9a9f81..a4ff8238ce82425a479f236f396563eb5cf7c4d9 100644
--- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
+++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
@@ -267,12 +267,13 @@ public class InputMethodManagerCompatWrapper {
         final InputMethodSubtypeCompatWrapper currentIms = getCurrentInputMethodSubtype();
         final List<InputMethodInfoCompatWrapper> imiList = getEnabledInputMethodList();
         imiList.remove(myImi);
+        final PackageManager pm = mPackageManager;
         Collections.sort(imiList, new Comparator<InputMethodInfoCompatWrapper>() {
             @Override
             public int compare(InputMethodInfoCompatWrapper imi1,
                     InputMethodInfoCompatWrapper imi2) {
-                final CharSequence imiId1 = imi1.loadLabel(mPackageManager) + "/" + imi1.getId();
-                final CharSequence imiId2 = imi2.loadLabel(mPackageManager) + "/" + imi2.getId();
+                final CharSequence imiId1 = imi1.loadLabel(pm) + "/" + imi1.getId();
+                final CharSequence imiId2 = imi2.loadLabel(pm) + "/" + imi2.getId();
                 return imiId1.toString().compareTo(imiId2.toString());
             }
         });
@@ -302,6 +303,7 @@ public class InputMethodManagerCompatWrapper {
             index++;
         }
 
+        final InputMethodServiceCompatWrapper service = mService;
         final OnClickListener buttonListener = new OnClickListener() {
             @Override
             public void onClick(DialogInterface di, int whichButton) {
@@ -309,10 +311,9 @@ public class InputMethodManagerCompatWrapper {
                 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                         | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                         | Intent.FLAG_ACTIVITY_CLEAR_TOP);
-                mService.startActivity(intent);
+                service.startActivity(intent);
             }
         };
-        final InputMethodServiceCompatWrapper service = mService;
         final IBinder token = service.getWindow().getWindow().getAttributes().token;
         final OnClickListener selectionListener = new OnClickListener() {
             @Override
diff --git a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
index a9e48404a34da9124f5098da90e3815c7f67ace2..df55aee9469d18da32fcada5dfedfcb627a67f24 100644
--- a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
+++ b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
@@ -129,7 +129,7 @@ public class SuggestionSpanUtils {
         // TODO: Share the implementation for checking typed word validity between the IME
         // and the spell checker.
         final int flag = (sameAsTyped && !suggestedWords.mTypedWordValid)
-                ? ((int)OBJ_FLAG_EASY_CORRECT | (int)OBJ_FLAG_MISSPELLED)
+                ? (OBJ_FLAG_EASY_CORRECT | OBJ_FLAG_MISSPELLED)
                 : 0;
 
         final Object[] args =
diff --git a/java/src/com/android/inputmethod/compat/SuggestionsInfoCompatUtils.java b/java/src/com/android/inputmethod/compat/SuggestionsInfoCompatUtils.java
index 6a0d4dd9e41fdfa728e621ca932fc06f00621acb..723ec286243d648de430a6d5a835fe87f9247b78 100644
--- a/java/src/com/android/inputmethod/compat/SuggestionsInfoCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/SuggestionsInfoCompatUtils.java
@@ -24,7 +24,7 @@ public class SuggestionsInfoCompatUtils {
     private static final Field FIELD_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS = CompatUtils.getField(
             SuggestionsInfo.class, "RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS");
     private static final Integer OBJ_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS = (Integer) CompatUtils
-            .getFieldValue(null, null, FIELD_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS);;
+            .getFieldValue(null, null, FIELD_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS);
     private static final int RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS =
             OBJ_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS != null
                     ? OBJ_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS : 0;
@@ -34,7 +34,7 @@ public class SuggestionsInfoCompatUtils {
 
     /**
      * Returns the flag value of the attributes of the suggestions that can be obtained by
-     * {@link #getSuggestionsAttributes}: this tells that the text service thinks
+     * {@link SuggestionsInfo#getSuggestionsAttributes()}: this tells that the text service thinks
      * the result suggestions include highly recommended ones.
      */
     public static int getValueOf_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS() {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
index 16b4eafc917207063e0fde92a87af27223b0809f..275aacf36d622dffbf42644134b6d18f6e627569 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
@@ -42,13 +42,13 @@ public interface KeyboardActionListener {
      *
      * @param primaryCode this is the code of the key that was pressed
      * @param x x-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
-     *            {@link PointerTracker#onTouchEvent} or so, the value should be
-     *            {@link #NOT_A_TOUCH_COORDINATE}. If it's called on insertion from the suggestion
-     *            strip, it should be {@link #SUGGESTION_STRIP_COORDINATE}.
+     *            {@link PointerTracker} or so, the value should be {@link #NOT_A_TOUCH_COORDINATE}.
+     *            If it's called on insertion from the suggestion strip, it should be
+     *            {@link #SUGGESTION_STRIP_COORDINATE}.
      * @param y y-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
-     *            {@link PointerTracker#onTouchEvent} or so, the value should be
-     *            {@link #NOT_A_TOUCH_COORDINATE}. If it's called on insertion from the suggestion
-     *            strip, it should be {@link #SUGGESTION_STRIP_COORDINATE}.
+     *            {@link PointerTracker} or so, the value should be {@link #NOT_A_TOUCH_COORDINATE}.
+     *            If it's called on insertion from the suggestion strip, it should be
+     *            {@link #SUGGESTION_STRIP_COORDINATE}.
      */
     public void onCodeInput(int primaryCode, int x, int y);
 
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
index 8ec4405001722e1cbd5dc0bcf03b0a72155c8b6c..311d3dc9d9010fd92dc520394d718afaf3221ff4 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
@@ -252,7 +252,7 @@ public class BinaryDictionaryFileDumper {
      * also apply.
      *
      * @param input the stream to be copied.
-     * @param outputFile an outputstream to copy the data to.
+     * @param output an output stream to copy the data to.
      */
     private static void checkMagicAndCopyFileTo(final BufferedInputStream input,
             final FileOutputStream output) throws FileNotFoundException, IOException {
diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java
index 79bf33850884e7e2e106bd759ec81c3fa4d757b8..9d26a23437040717c1b3feb6479fddba41895f95 100644
--- a/java/src/com/android/inputmethod/latin/Dictionary.java
+++ b/java/src/com/android/inputmethod/latin/Dictionary.java
@@ -38,7 +38,7 @@ public abstract class Dictionary {
 
     /**
      * Interface to be implemented by classes requesting words to be fetched from the dictionary.
-     * @see #getWords(WordComposer, WordCallback)
+     * @see #getWords(WordComposer, WordCallback, ProximityInfo)
      */
     public interface WordCallback {
         /**
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 9390571ebb27ec50461a1e788657a69b3a27c539..e6094d9e16342342c5aafbeabe45a76ed8d0e4b6 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -68,7 +68,6 @@ import com.android.inputmethod.keyboard.KeyboardId;
 import com.android.inputmethod.keyboard.KeyboardSwitcher;
 import com.android.inputmethod.keyboard.KeyboardView;
 import com.android.inputmethod.keyboard.LatinKeyboardView;
-import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils;
 import com.android.inputmethod.latin.define.ProductionFlag;
 import com.android.inputmethod.latin.suggestions.SuggestionsView;
 
diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
index 732efadd68c14e4b24966f88750c467fc8461bdc..dc0868e7c38e8f4a25f1f3d1b81e0b9441c9efa2 100644
--- a/java/src/com/android/inputmethod/latin/LatinImeLogger.java
+++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
@@ -16,7 +16,6 @@
 
 package com.android.inputmethod.latin;
 
-import android.content.Context;
 import android.content.SharedPreferences;
 import android.view.inputmethod.EditorInfo;
 
diff --git a/java/src/com/android/inputmethod/latin/ResearchLogger.java b/java/src/com/android/inputmethod/latin/ResearchLogger.java
index f39f082bc7efd498bd7d42e8636545c1ff65793f..570333cb731b1b1619ab7ae1d2abe39daaac9d86 100644
--- a/java/src/com/android/inputmethod/latin/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/latin/ResearchLogger.java
@@ -179,8 +179,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
         }
         if (prefs != null) {
             sIsLogging = prefs.getBoolean(PREF_USABILITY_STUDY_MODE, false);
+            prefs.registerOnSharedPreferenceChangeListener(this);
         }
-        prefs.registerOnSharedPreferenceChangeListener(this);
     }
 
     /**
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 555a49ef4099a8eba4a885bfe26a7b16479ebaef..bd8532ebdd9ba932680dd5cb281f34fcb346edc4 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -144,9 +144,7 @@ public class WordComposer {
     }
 
     /**
-     * Add a new keystroke, with codes[0] containing the pressed key's unicode and the rest of
-     * the array containing unicode for adjacent keys, sorted by reducing probability/proximity.
-     * @param codes the array of unicode values
+     * Add a new keystroke, with the pressed key's code point with the touch point coordinates.
      */
     private void add(int primaryCode, int keyX, int keyY) {
         final int newIndex = size();