diff --git a/java/proguard.flags b/java/proguard.flags
index 1633522..1711b99 100644
--- a/java/proguard.flags
+++ b/java/proguard.flags
@@ -24,6 +24,10 @@
   *;
 }
 
+-keep class com.android.inputmethod.latin.ResizableIntArray {
+  *;
+}
+
 -keep class com.android.inputmethod.latin.spellcheck.SpellCheckerSettingsFragment {
   *;
 }
diff --git a/java/res/values-fa/strings.xml b/java/res/values-fa/strings.xml
index 22a0d2c..9896864 100644
--- a/java/res/values-fa/strings.xml
+++ b/java/res/values-fa/strings.xml
@@ -118,7 +118,7 @@
     <string name="notify_session_log_not_deleted" msgid="2592908998810755970">"گزارش جلسه حذف نشد"</string>
     <string name="notify_session_history_logged" msgid="7723983399468056391">"سابقه جلسه گزارش شد"</string>
     <string name="notify_session_history_not_logged" msgid="6597910011368015361">"خطا: سابقه جلسه گزارش نشد"</string>
-    <string name="notify_session_logging_enabled" msgid="8549561596936177661">"گزارش جلسه توانا شد"</string>
+    <string name="notify_session_logging_enabled" msgid="8549561596936177661">"گزارش جلسه فعال شد"</string>
     <string name="select_language" msgid="3693815588777926848">"زبان‌های ورودی"</string>
     <string name="hint_add_to_dictionary" msgid="573678656946085380">"برای ذخیره دوباره لمس کنید"</string>
     <string name="has_dictionary" msgid="6071847973466625007">"دیکشنری موجود است"</string>
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index fb98af3..b05cc70 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -94,7 +94,7 @@
     // The maximum key label width in the proportion to the key width.
     private static final float MAX_LABEL_RATIO = 0.90f;
 
-    private final static int ALPHA_OPAQUE = 255;
+    public final static int ALPHA_OPAQUE = 255;
 
     // Main keyboard
     private Keyboard mKeyboard;
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 1eae2c1..36d3664 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -80,7 +80,6 @@
     // Stuff to draw language name on spacebar.
     private final int mLanguageOnSpacebarFinalAlpha;
     private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
-    private static final int ALPHA_OPAQUE = 255;
     private boolean mNeedsToDisplayLanguage;
     private boolean mHasMultipleEnabledIMEsOrSubtypes;
     private int mLanguageOnSpacebarAnimAlpha = ALPHA_OPAQUE;
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index ea4d93a..b002ae9 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -121,6 +121,8 @@
     private static boolean sConfigGestureInputEnabledByBuildConfig;
 
     private static final ArrayList<PointerTracker> sTrackers = new ArrayList<PointerTracker>();
+    private static final InputPointers sAggregratedPointers = new InputPointers(
+            GestureStroke.DEFAULT_CAPACITY);
     private static PointerTrackerQueue sPointerTrackerQueue;
     // HACK: Change gesture detection criteria depending on this variable.
     // TODO: Find more comprehensive ways to detect a gesture start.
@@ -257,23 +259,19 @@
     // TODO: To handle multi-touch gestures we may want to move this method to
     // {@link PointerTrackerQueue}.
     private static InputPointers getIncrementalBatchPoints() {
-        // TODO: Avoid creating a new instance here?
-        final InputPointers pointers = new InputPointers(GestureStroke.DEFAULT_CAPACITY);
         for (final PointerTracker tracker : sTrackers) {
-            tracker.mGestureStroke.appendIncrementalBatchPoints(pointers);
+            tracker.mGestureStroke.appendIncrementalBatchPoints(sAggregratedPointers);
         }
-        return pointers;
+        return sAggregratedPointers;
     }
 
     // TODO: To handle multi-touch gestures we may want to move this method to
     // {@link PointerTrackerQueue}.
     private static InputPointers getAllBatchPoints() {
-        // TODO: Avoid creating a new instance here?
-        final InputPointers pointers = new InputPointers(GestureStroke.DEFAULT_CAPACITY);
         for (final PointerTracker tracker : sTrackers) {
-            tracker.mGestureStroke.appendAllBatchPoints(pointers);
+            tracker.mGestureStroke.appendAllBatchPoints(sAggregratedPointers);
         }
-        return pointers;
+        return sAggregratedPointers;
     }
 
     // TODO: To handle multi-touch gestures we may want to move this method to
@@ -282,6 +280,7 @@
         for (final PointerTracker tracker : sTrackers) {
             tracker.mGestureStroke.reset();
         }
+        sAggregratedPointers.reset();
     }
 
     private PointerTracker(int id, KeyEventHandler handler) {
@@ -645,6 +644,8 @@
             if (sIsGestureEnabled && mIsAlphabetKeyboard && key != null
                     && Keyboard.isLetterCode(key.mCode)) {
                 mIsPossibleGesture = true;
+                // TODO: pointer times should be relative to first down even in entire batch input
+                // instead of resetting to 0 for each new down event.
                 mGestureStroke.addPoint(x, y, 0, false);
             }
         }
@@ -869,7 +870,9 @@
             }
             return;
         }
-
+        // This event will be recognized as a regular code input. Clear unused batch points so they
+        // are not mistakenly included in the next batch event.
+        clearBatchInputPointsOfAllPointerTrackers();
         if (mKeyAlreadyProcessed)
             return;
         if (mCurrentKey != null && !mCurrentKey.isRepeatable()) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
index 6f392f1..16c8410 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
@@ -27,6 +27,7 @@
     private float mLength;
     private float mAngle;
     private int mIncrementalRecognitionSize;
+    private int mLastIncrementalBatchSize;
     private long mLastPointTime;
     private int mLastPointX;
     private int mLastPointY;
@@ -73,6 +74,7 @@
         mLength = 0;
         mAngle = 0;
         mIncrementalRecognitionSize = 0;
+        mLastIncrementalBatchSize = 0;
         mLastPointTime = 0;
         mInputPointers.reset();
     }
@@ -126,11 +128,15 @@
     }
 
     public void appendAllBatchPoints(final InputPointers out) {
-        out.append(mInputPointers, 0, mInputPointers.getPointerSize());
+        final int size = mInputPointers.getPointerSize();
+        out.append(mInputPointers, mLastIncrementalBatchSize, size - mLastIncrementalBatchSize);
+        mLastIncrementalBatchSize = size;
     }
 
     public void appendIncrementalBatchPoints(final InputPointers out) {
-        out.append(mInputPointers, 0, mIncrementalRecognitionSize);
+        out.append(mInputPointers, mLastIncrementalBatchSize,
+                mIncrementalRecognitionSize - mLastIncrementalBatchSize);
+        mLastIncrementalBatchSize = mIncrementalRecognitionSize;
     }
 
     private static float getDistance(final int p1x, final int p1y,
diff --git a/java/src/com/android/inputmethod/latin/ResizableIntArray.java b/java/src/com/android/inputmethod/latin/ResizableIntArray.java
index 2079c0e..6feae9c 100644
--- a/java/src/com/android/inputmethod/latin/ResizableIntArray.java
+++ b/java/src/com/android/inputmethod/latin/ResizableIntArray.java
@@ -23,11 +23,18 @@
     private int[] mArray;
     private int mLength;
 
-    public ResizableIntArray(int capacity) {
+    public ResizableIntArray(final int capacity) {
         reset(capacity);
     }
 
-    public void add(int index, int val) {
+    public int get(final int index) {
+        if (index < 0 || index >= mLength) {
+            throw new ArrayIndexOutOfBoundsException("length=" + mLength + "; index=" + index);
+        }
+        return mArray[index];
+    }
+
+    public void add(final int index, final int val) {
         if (mLength < index + 1) {
             mLength = index;
             add(val);
@@ -36,14 +43,14 @@
         }
     }
 
-    public void add(int val) {
+    public void add(final int val) {
         final int nextLength = mLength + 1;
         ensureCapacity(nextLength);
         mArray[mLength] = val;
         mLength = nextLength;
     }
 
-    private void ensureCapacity(int minimumCapacity) {
+    private void ensureCapacity(final int minimumCapacity) {
         if (mArray.length < minimumCapacity) {
             final int nextCapacity = mArray.length * 2;
             // The following is the same as newLength =
@@ -60,9 +67,12 @@
         return mLength;
     }
 
-    // TODO: Implement setLength(int).
+    public void setLength(final int newLength) {
+        ensureCapacity(newLength);
+        mLength = newLength;
+    }
 
-    public void reset(int capacity) {
+    public void reset(final int capacity) {
         // TODO: Implement primitive array pool.
         mArray = new int[capacity];
         mLength = 0;
@@ -72,20 +82,20 @@
         return mArray;
     }
 
-    public void set(ResizableIntArray ip) {
+    public void set(final ResizableIntArray ip) {
         // TODO: Implement primitive array pool.
         mArray = ip.mArray;
         mLength = ip.mLength;
     }
 
-    public void copy(ResizableIntArray ip) {
+    public void copy(final ResizableIntArray ip) {
         // TODO: Avoid useless coping of values.
         ensureCapacity(ip.mLength);
         System.arraycopy(ip.mArray, 0, mArray, 0, ip.mLength);
         mLength = ip.mLength;
     }
 
-    public void append(ResizableIntArray src, int startPos, int length) {
+    public void append(final ResizableIntArray src, final int startPos, final int length) {
         final int currentLength = mLength;
         final int newLength = currentLength + length;
         ensureCapacity(newLength);
diff --git a/tests/src/com/android/inputmethod/latin/ResizableIntArrayTests.java b/tests/src/com/android/inputmethod/latin/ResizableIntArrayTests.java
index 8b869b6..80e5f9c 100644
--- a/tests/src/com/android/inputmethod/latin/ResizableIntArrayTests.java
+++ b/tests/src/com/android/inputmethod/latin/ResizableIntArrayTests.java
@@ -23,49 +23,141 @@
 
     public void testNewInstance() {
         final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
-        assertEquals("new instance length", 0, src.getLength());
-        assertNotNull("new instance array", src.getPrimitiveArray());
-    }
-
-    public void testReset() {
-        final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
         final int[] array = src.getPrimitiveArray();
-
-        src.reset(DEFAULT_CAPACITY);
-        assertEquals("length after reset", 0, src.getLength());
-        assertNotSame("array after reset", array, src.getPrimitiveArray());
+        assertEquals("new instance length", 0, src.getLength());
+        assertNotNull("new instance array", array);
+        assertEquals("new instance array length", DEFAULT_CAPACITY, array.length);
     }
 
     public void testAdd() {
         final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
-        final int limit = src.getPrimitiveArray().length * 2 + 10;
+        final int[] array = src.getPrimitiveArray();
+        int[] array2 = null, array3 = null;
+        final int limit = DEFAULT_CAPACITY * 2 + 10;
         for (int i = 0; i < limit; i++) {
             src.add(i);
             assertEquals("length after add " + i, i + 1, src.getLength());
+            if (i == DEFAULT_CAPACITY) array2 = src.getPrimitiveArray();
+            if (i == DEFAULT_CAPACITY * 2) array3 = src.getPrimitiveArray();
+            if (i < DEFAULT_CAPACITY) {
+                assertSame("array after add " + i, array, src.getPrimitiveArray());
+            } else if (i < DEFAULT_CAPACITY * 2) {
+                assertSame("array after add " + i, array2, src.getPrimitiveArray());
+            } else if (i < DEFAULT_CAPACITY * 3) {
+                assertSame("array after add " + i, array3, src.getPrimitiveArray());
+            }
         }
         for (int i = 0; i < limit; i++) {
-            assertEquals("value at " + i, i, src.getPrimitiveArray()[i]);
+            assertEquals("value at " + i, i, src.get(i));
         }
     }
 
     public void testAddAt() {
         final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
-        final int limit = 1000, step = 100;
+        final int limit = DEFAULT_CAPACITY * 10, step = DEFAULT_CAPACITY * 2;
         for (int i = 0; i < limit; i += step) {
             src.add(i, i);
             assertEquals("length after add at " + i, i + 1, src.getLength());
         }
         for (int i = 0; i < limit; i += step) {
-            assertEquals("value at " + i, i, src.getPrimitiveArray()[i]);
+            assertEquals("value at " + i, i, src.get(i));
+        }
+    }
+
+    public void testGet() {
+        final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
+        try {
+            final int value = src.get(0);
+            fail("get(0) shouldn't succeed");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // success
+        }
+        try {
+            final int value = src.get(DEFAULT_CAPACITY);
+            fail("get(DEFAULT_CAPACITY) shouldn't succeed");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // success
+        }
+
+        final int index = DEFAULT_CAPACITY / 2;
+        src.add(index, 100);
+        assertEquals("legth after add at " + index, index + 1, src.getLength());
+        assertEquals("value after add at " + index, 100, src.get(index));
+        assertEquals("value after add at 0", 0, src.get(0));
+        try {
+            final int value = src.get(src.getLength());
+            fail("get(length) shouldn't succeed");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // success
+        }
+    }
+
+    public void testReset() {
+        final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
+        final int[] array = src.getPrimitiveArray();
+        for (int i = 0; i < DEFAULT_CAPACITY; i++) {
+            src.add(i);
+            assertEquals("length after add " + i, i + 1, src.getLength());
+        }
+
+        final int smallerLength = DEFAULT_CAPACITY / 2;
+        src.reset(smallerLength);
+        final int[] array2 = src.getPrimitiveArray();
+        assertEquals("length after reset", 0, src.getLength());
+        assertNotSame("array after reset", array, array2);
+
+        int[] array3 = null;
+        for (int i = 0; i < DEFAULT_CAPACITY; i++) {
+            src.add(i);
+            assertEquals("length after add " + i, i + 1, src.getLength());
+            if (i == smallerLength) array3 = src.getPrimitiveArray();
+            if (i < smallerLength) {
+                assertSame("array after add " + i, array2, src.getPrimitiveArray());
+            } else if (i < smallerLength * 2) {
+                assertSame("array after add " + i, array3, src.getPrimitiveArray());
+            }
+        }
+    }
+
+    public void testSetLength() {
+        final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
+        final int[] array = src.getPrimitiveArray();
+        for (int i = 0; i < DEFAULT_CAPACITY; i++) {
+            src.add(i);
+            assertEquals("length after add " + i, i + 1, src.getLength());
+        }
+
+        final int largerLength = DEFAULT_CAPACITY * 2;
+        src.setLength(largerLength);
+        final int[] array2 = src.getPrimitiveArray();
+        assertEquals("length after larger setLength", largerLength, src.getLength());
+        assertNotSame("array after larger setLength", array, array2);
+        assertEquals("array length after larger setLength", largerLength, array2.length);
+        for (int i = 0; i < DEFAULT_CAPACITY; i++) {
+            assertEquals("value at " + i, i, src.get(i));
+        }
+        for (int i = DEFAULT_CAPACITY; i < largerLength; i++) {
+            assertEquals("value at " + i, 0, src.get(i));
+        }
+
+        final int smallerLength = DEFAULT_CAPACITY / 2;
+        src.setLength(smallerLength);
+        final int[] array3 = src.getPrimitiveArray();
+        assertEquals("length after smaller setLength", smallerLength, src.getLength());
+        assertSame("array after smaller setLength", array2, array3);
+        assertEquals("array length after smaller setLength", largerLength, array3.length);
+        for (int i = 0; i < smallerLength; i++) {
+            assertEquals("value at " + i, i, src.get(i));
         }
     }
 
     public void testSet() {
         final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
-        final int limit = src.getPrimitiveArray().length * 2 + 10;
+        final int limit = DEFAULT_CAPACITY * 2 + 10;
         for (int i = 0; i < limit; i++) {
             src.add(i);
         }
+
         final ResizableIntArray dst = new ResizableIntArray(DEFAULT_CAPACITY);
         dst.set(src);
         assertEquals("length after set", dst.getLength(), src.getLength());
@@ -74,27 +166,40 @@
 
     public void testCopy() {
         final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
-        final int limit = 100;
-        for (int i = 0; i < limit; i++) {
+        for (int i = 0; i < DEFAULT_CAPACITY; i++) {
             src.add(i);
         }
+
         final ResizableIntArray dst = new ResizableIntArray(DEFAULT_CAPACITY);
+        final int[] array = dst.getPrimitiveArray();
         dst.copy(src);
         assertEquals("length after copy", dst.getLength(), src.getLength());
+        assertSame("array after copy", array, dst.getPrimitiveArray());
         assertNotSame("array after copy", dst.getPrimitiveArray(), src.getPrimitiveArray());
-        final int length = dst.getLength();
         assertArrayEquals("values after copy",
-                dst.getPrimitiveArray(), 0, src.getPrimitiveArray(), 0, length);
+                dst.getPrimitiveArray(), 0, src.getPrimitiveArray(), 0, dst.getLength());
+
+        final int smallerLength = DEFAULT_CAPACITY / 2;
+        dst.reset(smallerLength);
+        final int[] array2 = dst.getPrimitiveArray();
+        dst.copy(src);
+        final int[] array3 = dst.getPrimitiveArray();
+        assertEquals("length after copy to smaller", dst.getLength(), src.getLength());
+        assertNotSame("array after copy to smaller", array2, array3);
+        assertNotSame("array after copy to smaller", array3, src.getPrimitiveArray());
+        assertArrayEquals("values after copy to smaller",
+                dst.getPrimitiveArray(), 0, src.getPrimitiveArray(), 0, dst.getLength());
     }
 
     public void testAppend() {
-        final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
-        final int srcLen = 100;
+        final int srcLen = DEFAULT_CAPACITY;
+        final ResizableIntArray src = new ResizableIntArray(srcLen);
         for (int i = 0; i < srcLen; i++) {
             src.add(i);
         }
-        final int dstLen = 50;
-        final ResizableIntArray dst = new ResizableIntArray(DEFAULT_CAPACITY);
+        final ResizableIntArray dst = new ResizableIntArray(DEFAULT_CAPACITY * 2);
+        final int[] array = dst.getPrimitiveArray();
+        final int dstLen = DEFAULT_CAPACITY / 2;
         for (int i = 0; i < dstLen; i++) {
             final int value = -i - 1;
             dst.add(value);
@@ -104,17 +209,31 @@
 
         dst.append(src, 0, 0);
         assertEquals("length after append zero", dstLen, dst.getLength());
+        assertSame("array after append zero", array, dst.getPrimitiveArray());
         assertArrayEquals("values after append zero",
                 dstCopy.getPrimitiveArray(), 0, dst.getPrimitiveArray(), 0, dstLen);
 
         dst.append(src, 0, srcLen);
         assertEquals("length after append", dstLen + srcLen, dst.getLength());
+        assertSame("array after append", array, dst.getPrimitiveArray());
         assertTrue("primitive length after append",
                 dst.getPrimitiveArray().length >= dstLen + srcLen);
         assertArrayEquals("original values after append",
                 dstCopy.getPrimitiveArray(), 0, dst.getPrimitiveArray(), 0, dstLen);
         assertArrayEquals("appended values after append",
                 src.getPrimitiveArray(), 0, dst.getPrimitiveArray(), dstLen, srcLen);
+
+        dst.append(src, 0, srcLen);
+        assertEquals("length after 2nd append", dstLen + srcLen * 2, dst.getLength());
+        assertNotSame("array after 2nd append", array, dst.getPrimitiveArray());
+        assertTrue("primitive length after 2nd append",
+                dst.getPrimitiveArray().length >= dstLen + srcLen * 2);
+        assertArrayEquals("original values after 2nd append",
+                dstCopy.getPrimitiveArray(), 0, dst.getPrimitiveArray(), 0, dstLen);
+        assertArrayEquals("appended values after 2nd append",
+                src.getPrimitiveArray(), 0, dst.getPrimitiveArray(), dstLen, srcLen);
+        assertArrayEquals("appended values after 2nd append",
+                src.getPrimitiveArray(), 0, dst.getPrimitiveArray(), dstLen + srcLen, srcLen);
     }
 
     private static void assertArrayEquals(String message, int[] expecteds, int expectedPos,
