diff --git a/native/jni/Android.mk b/native/jni/Android.mk
index df98680cac159510df082d7434abc2f6f2bc0a69..2f0fc2036c5e0835df10e4e1002a33f04b0aa361 100644
--- a/native/jni/Android.mk
+++ b/native/jni/Android.mk
@@ -50,11 +50,18 @@ LATIN_IME_CORE_SRC_FILES := \
     proximity_info.cpp \
     proximity_info_state.cpp \
     unigram_dictionary.cpp \
-    gesture/build_check.cpp
+    gesture/incremental_decoder_interface.cpp
+
+LATIN_IME_GESTURE_IMPL_SRC_FILES := \
+    gesture/impl/gesture_decoder_impl.cpp \
+    gesture/impl/incremental_decoder_impl.cpp \
+    gesture/impl/token_beam_impl.cpp \
+    gesture/impl/token_impl.cpp
 
 LOCAL_SRC_FILES := \
     $(LATIN_IME_JNI_SRC_FILES) \
-    $(addprefix $(LATIN_IME_SRC_DIR)/,$(LATIN_IME_CORE_SRC_FILES))
+    $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES)) \
+    $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_GESTURE_IMPL_SRC_FILES))
 
 ifeq ($(FLAG_DO_PROFILE), true)
     $(warning Making profiling version of native library)
@@ -79,21 +86,16 @@ include $(BUILD_STATIC_LIBRARY)
 ######################################
 include $(CLEAR_VARS)
 
-LOCAL_C_INCLUDES += $(LATIN_IME_SRC_FULLPATH_DIR) \
-    $(addprefix $(LATIN_IME_SRC_FULLPATH_DIR)/, gesture gesture/impl gesture/impl/header)
+LOCAL_C_INCLUDES = $(LATIN_IME_SRC_FULLPATH_DIR) $(LATIN_IME_SRC_FULLPATH_DIR)/gesture
 
 LOCAL_CFLAGS += -Werror -Wall
 
 # To suppress compiler warnings for unused variables/functions used for debug features etc.
 LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
 
-LATIN_IME_GESTURE_IMPL_SRC_FILES := \
-    gesture/impl/gesture_decoder_impl.cpp \
-    gesture/impl/incremental_decoder_impl.cpp \
-    gesture/impl/token_beam_impl.cpp \
-    gesture/impl/token_impl.cpp
-
-LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_SRC_DIR)/,$(LATIN_IME_GESTURE_IMPL_SRC_FILES))
+LOCAL_SRC_FILES := \
+    $(LATIN_IME_JNI_SRC_FILES) \
+    $(addprefix $(LATIN_IME_SRC_DIR)/,$(LATIN_IME_CORE_SRC_FILES))
 
 ifeq ($(FLAG_DO_PROFILE), true)
     $(warning Making profiling version of native library)
@@ -105,7 +107,7 @@ ifeq ($(FLAG_DBG), true)
 endif # FLAG_DBG
 endif # FLAG_DO_PROFILE
 
-LOCAL_MODULE := libjni_latinime_gesture_impl_static
+LOCAL_MODULE := libjni_latinime_common_static
 LOCAL_MODULE_TAGS := optional
 
 ifdef HISTORICAL_NDK_VERSIONS_ROOT # In the platform build system
@@ -119,7 +121,7 @@ include $(BUILD_STATIC_LIBRARY)
 include $(CLEAR_VARS)
 
 # All code in LOCAL_WHOLE_STATIC_LIBRARIES will be built into this shared library.
-LOCAL_WHOLE_STATIC_LIBRARIES := libjni_latinime_static libjni_latinime_gesture_impl_static
+LOCAL_WHOLE_STATIC_LIBRARIES := libjni_latinime_static
 
 ifdef HISTORICAL_NDK_VERSIONS_ROOT # In the platform build system
 LOCAL_SHARED_LIBRARIES := libstlport
diff --git a/native/jni/src/dictionary.cpp b/native/jni/src/dictionary.cpp
index 10ea9fe06dc12bb41ed247cedf05cd00ad34cd42..60f3c949bdfa20aaa6361fffa493c92685a35b39 100644
--- a/native/jni/src/dictionary.cpp
+++ b/native/jni/src/dictionary.cpp
@@ -22,6 +22,7 @@
 #include "binary_format.h"
 #include "defines.h"
 #include "dictionary.h"
+#include "incremental_decoder_interface.h"
 
 namespace latinime {
 
@@ -43,7 +44,8 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
     mUnigramDictionary = new UnigramDictionary(mDict + headerSize, typedLetterMultiplier,
             fullWordMultiplier, maxWordLength, maxWords, options);
     mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength);
-    mGestureDecoder = new GestureDecoder(maxWordLength, maxWords);
+    mGestureDecoder = IncrementalDecoderInterface::getGestureDecoderInstance(maxWordLength,
+            maxWords);
     mGestureDecoder->setDict(mUnigramDictionary, mBigramDictionary,
             mDict + headerSize /* dict root */, 0 /* root pos */);
 }
@@ -51,6 +53,7 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
 Dictionary::~Dictionary() {
     delete mUnigramDictionary;
     delete mBigramDictionary;
+    delete mGestureDecoder;
 }
 
 int Dictionary::getFrequency(const int32_t *word, int length) const {
diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h
index 8b47694318990e92d135943f9c3528f51a265537..2b0619c4641ead4a6e9f5405543076c1a29919bf 100644
--- a/native/jni/src/dictionary.h
+++ b/native/jni/src/dictionary.h
@@ -22,7 +22,7 @@
 #include "bigram_dictionary.h"
 #include "char_utils.h"
 #include "defines.h"
-#include "gesture/gesture_decoder.h"
+#include "incremental_decoder_interface.h"
 #include "proximity_info.h"
 #include "unigram_dictionary.h"
 #include "words_priority_queue_pool.h"
@@ -87,7 +87,7 @@ class Dictionary {
 
     const UnigramDictionary *mUnigramDictionary;
     const BigramDictionary *mBigramDictionary;
-    GestureDecoder *mGestureDecoder;
+    IncrementalDecoderInterface *mGestureDecoder;
 };
 
 // public static utility methods
diff --git a/native/jni/src/gesture/gesture_decoder.h b/native/jni/src/gesture/gesture_decoder.h
deleted file mode 100644
index 8e79555bd6358d4b44b33b6b34a8b045331fcdb5..0000000000000000000000000000000000000000
--- a/native/jni/src/gesture/gesture_decoder.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#ifndef LATINIME_GESTURE_DECODER_H
-#define LATINIME_GESTURE_DECODER_H
-
-#include "defines.h"
-#include "gesture_decoder_impl.h"
-
-namespace latinime {
-
-class GestureDecoder : public GestureDecoderImpl {
-
- public:
-    GestureDecoder(int maxWordLength, int maxWords) :
-            GestureDecoderImpl(maxWordLength, maxWords) {
-    }
-
- private:
-    DISALLOW_IMPLICIT_CONSTRUCTORS(GestureDecoder);
-};
-} // namespace latinime
-
-#endif // LATINIME_INCREMENTAL_DECODER_H
diff --git a/native/jni/src/gesture/impl/gesture_decoder_impl.cpp b/native/jni/src/gesture/impl/gesture_decoder_impl.cpp
index 59937a4d8ca5142db0e09d82a2c2261875a44889..035850eaddd8d52fe618791b5f4cea3ff5948edd 100644
--- a/native/jni/src/gesture/impl/gesture_decoder_impl.cpp
+++ b/native/jni/src/gesture/impl/gesture_decoder_impl.cpp
@@ -15,7 +15,26 @@
  */
 
 #include "gesture_decoder_impl.h"
+#include "incremental_decoder_interface.h"
 
 namespace latinime {
+
+// A factory method for GestureDecoderImpl
+static IncrementalDecoderInterface *getDecoderInstance(int maxWordLength, int maxWords) {
+    return new GestureDecoderImpl(maxWordLength, maxWords);
+}
+
+// An ad-hoc internal class to register the factory method defined above
+class GestureDecoderFactoryRegisterer {
+ public:
+    GestureDecoderFactoryRegisterer() {
+        IncrementalDecoderInterface::setGestureDecoderFactoryMethod(getDecoderInstance);
+    }
+ private:
+    DISALLOW_COPY_AND_ASSIGN(GestureDecoderFactoryRegisterer);
 };
-// namespace latinime
+
+// To invoke the GestureDecoderFactoryRegisterer constructor in the global constructor
+// Not sure, but can be static?
+GestureDecoderFactoryRegisterer gestureDecoderFactoryRegisterer;
+} // namespace latinime
diff --git a/native/jni/src/gesture/impl/gesture_decoder_impl.h b/native/jni/src/gesture/impl/gesture_decoder_impl.h
index 0ca89941ca5bfe43f6118a848d3b73a34904c3e2..6de807b396d1d75f5470c203a315f37e673a73b3 100644
--- a/native/jni/src/gesture/impl/gesture_decoder_impl.h
+++ b/native/jni/src/gesture/impl/gesture_decoder_impl.h
@@ -18,15 +18,14 @@
 #define LATINIME_GESTURE_DECODER_IMPL_H
 
 #include "defines.h"
-#include "incremental_decoder.h"
+#include "incremental_decoder_impl.h"
 
 namespace latinime {
 
-class GestureDecoderImpl : public IncrementalDecoder {
-
+class GestureDecoderImpl : public IncrementalDecoderImpl {
  public:
     GestureDecoderImpl(int maxWordLength, int maxWords) :
-            IncrementalDecoder(maxWordLength, maxWords) {
+            IncrementalDecoderImpl(maxWordLength, maxWords) {
     }
 
     int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
@@ -39,5 +38,4 @@ class GestureDecoderImpl : public IncrementalDecoder {
     DISALLOW_IMPLICIT_CONSTRUCTORS(GestureDecoderImpl);
 };
 } // namespace latinime
-
 #endif // LATINIME_GESTURE_DECODER_IMPL_H
diff --git a/native/jni/src/gesture/impl/incremental_decoder_impl.cpp b/native/jni/src/gesture/impl/incremental_decoder_impl.cpp
index b7e8b3bd1fe4bc7119bce47c995fade92483df7f..f2b76ed26e409797bf50919ec44f4e5fca048229 100644
--- a/native/jni/src/gesture/impl/incremental_decoder_impl.cpp
+++ b/native/jni/src/gesture/impl/incremental_decoder_impl.cpp
@@ -15,7 +15,26 @@
  */
 
 #include "incremental_decoder_impl.h"
+#include "incremental_decoder_interface.h"
 
 namespace latinime {
+
+// A factory method for IncrementalDecoderImpl
+static IncrementalDecoderInterface *getDecoderInstance(int maxWordLength, int maxWords) {
+    return new IncrementalDecoderImpl(maxWordLength, maxWords);
+}
+
+// An ad-hoc internal class to register the factory method defined above
+class IncrementalDecoderFactoryRegisterer {
+ public:
+    IncrementalDecoderFactoryRegisterer() {
+        IncrementalDecoderInterface::setIncrementalDecoderFactoryMethod(getDecoderInstance);
+    }
+ private:
+    DISALLOW_COPY_AND_ASSIGN(IncrementalDecoderFactoryRegisterer);
 };
-// namespace latinime
+
+// To invoke the IncrementalDecoderFactoryRegisterer constructor in the global constructor
+// Not sure, but can be static?
+IncrementalDecoderFactoryRegisterer incrementalDecoderFactoryRegisterer;
+} // namespace latinime
diff --git a/native/jni/src/gesture/impl/incremental_decoder_impl.h b/native/jni/src/gesture/impl/incremental_decoder_impl.h
index 84121e8e29f742eb46dffa0e38199f1b440f5dfb..50ed1430378b597eb9420ec877f223d4196e543d 100644
--- a/native/jni/src/gesture/impl/incremental_decoder_impl.h
+++ b/native/jni/src/gesture/impl/incremental_decoder_impl.h
@@ -17,25 +17,30 @@
 #ifndef LATINIME_INCREMENTAL_DECODER_IMPL_H
 #define LATINIME_INCREMENTAL_DECODER_IMPL_H
 
-#include "bigram_dictionary.h"
 #include "defines.h"
 #include "incremental_decoder_interface.h"
-#include "unigram_dictionary.h"
 
 namespace latinime {
 
-class IncrementalDecoderImpl : IncrementalDecoderInterface {
+class UnigramDictionary;
+class BigramDictionary;
 
+class IncrementalDecoderImpl : public IncrementalDecoderInterface {
  public:
-     IncrementalDecoderImpl(int maxWordLength, int maxWords) { };
-     void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
-             const uint8_t *dictRoot, int rootPos) { };
-     void setPrevWord(const int32_t *prevWord, int prevWordLength) { };
-     void reset() { };
+    IncrementalDecoderImpl(int maxWordLength, int maxWords) { };
+    void setDict(const UnigramDictionary *dict, const BigramDictionary *bigram,
+            const uint8_t *dictRoot, int rootPos) { };
+    void setPrevWord(const int32_t *prevWord, int prevWordLength) { };
+    void reset() { };
+
+    int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
+            int *pointerIds, int *codes, int inputSize, int commitPoint,
+            unsigned short *outWords, int *frequencies, int *outputIndices) {
+        return 0;
+    }
 
  private:
      DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalDecoderImpl);
 };
 } // namespace latinime
-
 #endif // LATINIME_INCREMENTAL_DECODER_IMPL_H
diff --git a/native/jni/src/gesture/impl/token_beam_impl.cpp b/native/jni/src/gesture/impl/token_beam_impl.cpp
index b2b73c25c81e725a292b2682df61321f5751d6c1..ffac4dd394f6e59ff9921d286ac64992621c71da 100644
--- a/native/jni/src/gesture/impl/token_beam_impl.cpp
+++ b/native/jni/src/gesture/impl/token_beam_impl.cpp
@@ -17,5 +17,4 @@
 #include "token_beam_impl.h"
 
 namespace latinime {
-};
-// namespace latinime
+} // namespace latinime
diff --git a/native/jni/src/gesture/impl/token_beam_impl.h b/native/jni/src/gesture/impl/token_beam_impl.h
index 33250569750a5801216b46b9594a35a4924e3735..50de9258b384531c5d000040e6588148a971a2b3 100644
--- a/native/jni/src/gesture/impl/token_beam_impl.h
+++ b/native/jni/src/gesture/impl/token_beam_impl.h
@@ -26,5 +26,4 @@ class TokenBeamImpl {
     DISALLOW_IMPLICIT_CONSTRUCTORS(TokenBeamImpl);
 };
 } // namespace latinime
-
 #endif // LATINIME_TOKEN_BEAM_IMPL_H
diff --git a/native/jni/src/gesture/impl/token_impl.cpp b/native/jni/src/gesture/impl/token_impl.cpp
index c7efeb18896dec9eb2699c03ccaaa59d6ab70d94..fa667f03a4d8edcc8f15c79d4a3f1489365d39b3 100644
--- a/native/jni/src/gesture/impl/token_impl.cpp
+++ b/native/jni/src/gesture/impl/token_impl.cpp
@@ -17,5 +17,4 @@
 #include "token_impl.h"
 
 namespace latinime {
-};
-// namespace latinime
+} // namespace latinime
diff --git a/native/jni/src/gesture/impl/token_impl.h b/native/jni/src/gesture/impl/token_impl.h
index 0ed7d002077037709bb7ae8dd7cd5dfd2ee57944..5f2368a93c4357d80080f500f690e7e18722679b 100644
--- a/native/jni/src/gesture/impl/token_impl.h
+++ b/native/jni/src/gesture/impl/token_impl.h
@@ -26,5 +26,4 @@ struct TokenImpl {
     DISALLOW_IMPLICIT_CONSTRUCTORS(TokenImpl);
 };
 } // namespace latinime
-
 #endif // LATINIME_TOKEN_IMPL_H
diff --git a/native/jni/src/gesture/incremental_decoder.h b/native/jni/src/gesture/incremental_decoder.h
deleted file mode 100644
index fe935529f113181b1de353779f6035750958be93..0000000000000000000000000000000000000000
--- a/native/jni/src/gesture/incremental_decoder.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#ifndef LATINIME_INCREMENTAL_DECODER_H
-#define LATINIME_INCREMENTAL_DECODER_H
-
-#include "defines.h"
-#include "incremental_decoder_impl.h"
-
-namespace latinime {
-
-class IncrementalDecoder : public IncrementalDecoderImpl {
-
- public:
-     IncrementalDecoder(int maxWordLength, int maxWords) :
-             IncrementalDecoderImpl(maxWordLength, maxWords) {
-     }
-
- private:
-     DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalDecoder);
-};
-} // namespace latinime
-
-#endif // LATINIME_INCREMENTAL_DECODER_H
diff --git a/native/jni/src/gesture/build_check.cpp b/native/jni/src/gesture/incremental_decoder_interface.cpp
similarity index 67%
rename from native/jni/src/gesture/build_check.cpp
rename to native/jni/src/gesture/incremental_decoder_interface.cpp
index 8ec94f5934850abc149eb347f912572590c9cffe..9fb2a17aa4cb506f2ec87e895b47c1209661d8a7 100644
--- a/native/jni/src/gesture/build_check.cpp
+++ b/native/jni/src/gesture/incremental_decoder_interface.cpp
@@ -14,8 +14,11 @@
  * limitations under the License.
  */
 
-#include "gesture_decoder.h"
+#include "incremental_decoder_interface.h"
 
 namespace latinime {
-};
-// namespace latinime
+    IncrementalDecoderInterface *
+            (*IncrementalDecoderInterface::sGestureDecoderFactoryMethod)(int, int) = 0;
+    IncrementalDecoderInterface *
+            (*IncrementalDecoderInterface::sIncrementalDecoderFactoryMethod)(int, int) = 0;
+} // namespace latinime
diff --git a/native/jni/src/gesture/incremental_decoder_interface.h b/native/jni/src/gesture/incremental_decoder_interface.h
index 565f89c909acde03c1aa43b72adef3554f8f82a8..1f92affb647c68c6ad530e7ab40935d9764a8d8f 100644
--- a/native/jni/src/gesture/incremental_decoder_interface.h
+++ b/native/jni/src/gesture/incremental_decoder_interface.h
@@ -17,15 +17,16 @@
 #ifndef LATINIME_INCREMENTAL_DECODER_INTERFACE_H
 #define LATINIME_INCREMENTAL_DECODER_INTERFACE_H
 
-#include "bigram_dictionary.h"
+#include <stdint.h>
 #include "defines.h"
-#include "proximity_info.h"
-#include "unigram_dictionary.h"
 
 namespace latinime {
 
-class IncrementalDecoderInterface {
+class UnigramDictionary;
+class BigramDictionary;
+class ProximityInfo;
 
+class IncrementalDecoderInterface {
  public:
     virtual int getSuggestions(ProximityInfo *pInfo, int *inputXs, int *inputYs, int *times,
             int *pointerIds, int *codes, int inputSize, int commitPoint,
@@ -35,7 +36,35 @@ class IncrementalDecoderInterface {
             const uint8_t *dictRoot, int rootPos) = 0;
     virtual void setPrevWord(const int32_t *prevWord, int prevWordLength) = 0;
     virtual ~IncrementalDecoderInterface() { };
+
+    static IncrementalDecoderInterface *getGestureDecoderInstance(int maxWordLength, int maxWords) {
+        if (sGestureDecoderFactoryMethod) {
+            return sGestureDecoderFactoryMethod(maxWordLength, maxWords);
+        }
+        return 0;
+    }
+
+    static IncrementalDecoderInterface *getIncrementalDecoderInstance(int maxWordLength,
+            int maxWords) {
+        if (sIncrementalDecoderFactoryMethod) {
+            return sIncrementalDecoderFactoryMethod(maxWordLength, maxWords);
+        }
+        return 0;
+    }
+
+    static void setGestureDecoderFactoryMethod(
+            IncrementalDecoderInterface *(*factoryMethod)(int, int)) {
+        sGestureDecoderFactoryMethod = factoryMethod;
+    }
+
+    static void setIncrementalDecoderFactoryMethod(
+            IncrementalDecoderInterface *(*factoryMethod)(int, int)) {
+        sIncrementalDecoderFactoryMethod = factoryMethod;
+    }
+
+ private:
+    static IncrementalDecoderInterface *(*sGestureDecoderFactoryMethod)(int, int);
+    static IncrementalDecoderInterface *(*sIncrementalDecoderFactoryMethod)(int, int);
 };
 } // namespace latinime
-
 #endif // LATINIME_INCREMENTAL_DECODER_INTERFACE_H