diff --git a/native/Android.mk b/native/Android.mk
index 4727b1e392b9ce5c8cbd67090edda5f9e9cf47e4..d9f4f1d38db5a3bb0a464c32080eb21c56247fde 100644
--- a/native/Android.mk
+++ b/native/Android.mk
@@ -11,7 +11,7 @@ LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
 LOCAL_SRC_FILES := \
     jni/com_android_inputmethod_keyboard_ProximityInfo.cpp \
     jni/com_android_inputmethod_latin_BinaryDictionary.cpp \
-    jni/onload.cpp \
+    jni/jni_common.cpp \
     src/bigram_dictionary.cpp \
     src/char_utils.cpp \
     src/dictionary.cpp \
diff --git a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
index 3db89edf149e451b5c2b3b64be623054897ddb21..f3e2a7e60a4d7792f33a371e71bea5707740635e 100644
--- a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
+++ b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
@@ -19,28 +19,15 @@
 
 #include "com_android_inputmethod_keyboard_ProximityInfo.h"
 #include "jni.h"
+#include "jni_common.h"
 #include "proximity_info.h"
 
 #include <assert.h>
 #include <errno.h>
 #include <stdio.h>
 
-// ----------------------------------------------------------------------------
-
 namespace latinime {
 
-//
-// helper function to throw an exception
-//
-static void throwException(JNIEnv *env, const char* ex, const char* fmt, int data) {
-    if (jclass cls = env->FindClass(ex)) {
-        char msg[1000];
-        snprintf(msg, sizeof(msg), fmt, data);
-        env->ThrowNew(cls, msg);
-        env->DeleteLocalRef(cls);
-    }
-}
-
 static jint latinime_Keyboard_setProximityInfo(JNIEnv *env, jobject object,
         jint maxProximityCharsSize, jint displayWidth, jint displayHeight, jint gridWidth,
         jint gridHeight, jintArray proximityCharsArray) {
@@ -57,34 +44,15 @@ static void latinime_Keyboard_release(JNIEnv *env, jobject object, jint proximit
     delete pi;
 }
 
-// ----------------------------------------------------------------------------
-
 static JNINativeMethod sKeyboardMethods[] = {
     {"setProximityInfoNative", "(IIIII[I)I", (void*)latinime_Keyboard_setProximityInfo},
     {"releaseProximityInfoNative", "(I)V", (void*)latinime_Keyboard_release}
 };
 
-static int registerNativeMethods(JNIEnv* env, const char* className, JNINativeMethod* gMethods,
-        int numMethods) {
-    jclass clazz;
-
-    clazz = env->FindClass(className);
-    if (clazz == NULL) {
-        LOGE("Native registration unable to find class '%s'", className);
-        return JNI_FALSE;
-    }
-    if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
-        LOGE("RegisterNatives failed for '%s'", className);
-        return JNI_FALSE;
-    }
-
-    return JNI_TRUE;
-}
-
 int register_ProximityInfo(JNIEnv *env) {
     const char* const kClassPathName = "com/android/inputmethod/keyboard/ProximityInfo";
     return registerNativeMethods(env, kClassPathName, sKeyboardMethods,
             sizeof(sKeyboardMethods) / sizeof(sKeyboardMethods[0]));
 }
 
-}; // namespace latinime
+} // namespace latinime
diff --git a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.h b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.h
index bdeeb8f3756f402fb2d28fd21c8a97f433ab0fef..4a1e83b092cde32e4e4c579da8a993766322bf6f 100644
--- a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.h
+++ b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.h
@@ -21,7 +21,9 @@
 #include "jni.h"
 
 namespace latinime {
+
 int register_ProximityInfo(JNIEnv *env);
+
 }
 
 #endif // _COM_ANDROID_INPUTMETHOD_KEYBOARD_PROXIMITYINFO_H
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
index 4b61c14144f7222a6d33350928a8d8f869299b6c..ce874d8d40bc128acdc115125cdfe34ad276cd01 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -20,6 +20,7 @@
 #include "com_android_inputmethod_latin_BinaryDictionary.h"
 #include "dictionary.h"
 #include "jni.h"
+#include "jni_common.h"
 #include "proximity_info.h"
 
 #include <assert.h>
@@ -35,22 +36,8 @@
 #include <stdlib.h>
 #endif // USE_MMAP_FOR_DICTIONARY
 
-// ----------------------------------------------------------------------------
-
 namespace latinime {
 
-//
-// helper function to throw an exception
-//
-static void throwException(JNIEnv *env, const char* ex, const char* fmt, int data) {
-    if (jclass cls = env->FindClass(ex)) {
-        char msg[1000];
-        snprintf(msg, sizeof(msg), fmt, data);
-        env->ThrowNew(cls, msg);
-        env->DeleteLocalRef(cls);
-    }
-}
-
 static jint latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
         jstring sourceDir, jlong dictOffset, jlong dictSize,
         jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords,
@@ -208,8 +195,6 @@ static void latinime_BinaryDictionary_close(JNIEnv *env, jobject object, jint di
     delete dictionary;
 }
 
-// ----------------------------------------------------------------------------
-
 static JNINativeMethod sMethods[] = {
     {"openNative", "(Ljava/lang/String;JJIIIII)I", (void*)latinime_BinaryDictionary_open},
     {"closeNative", "(I)V", (void*)latinime_BinaryDictionary_close},
@@ -218,27 +203,10 @@ static JNINativeMethod sMethods[] = {
     {"getBigramsNative", "(I[CI[II[C[IIII)I", (void*)latinime_BinaryDictionary_getBigrams}
 };
 
-static int registerNativeMethods(JNIEnv* env, const char* className, JNINativeMethod* gMethods,
-        int numMethods) {
-    jclass clazz;
-
-    clazz = env->FindClass(className);
-    if (clazz == NULL) {
-        LOGE("Native registration unable to find class '%s'", className);
-        return JNI_FALSE;
-    }
-    if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
-        LOGE("RegisterNatives failed for '%s'", className);
-        return JNI_FALSE;
-    }
-
-    return JNI_TRUE;
-}
-
 int register_BinaryDictionary(JNIEnv *env) {
     const char* const kClassPathName = "com/android/inputmethod/latin/BinaryDictionary";
     return registerNativeMethods(env, kClassPathName, sMethods,
             sizeof(sMethods) / sizeof(sMethods[0]));
 }
 
-}; // namespace latinime
+} // namespace latinime
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.h b/native/jni/com_android_inputmethod_latin_BinaryDictionary.h
index f7cd81fa71e50d1a2c0202ca27d9cdb82b9a54d7..1b1ba7f0ffbdb2aa1962d6eeb43cb30c0accf735 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.h
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.h
@@ -21,7 +21,9 @@
 #include "jni.h"
 
 namespace latinime {
+
 int register_BinaryDictionary(JNIEnv *env);
+
 }
 
 #endif // _COM_ANDROID_INPUTMETHOD_LATIN_BINARYDICTIONARY_H
diff --git a/native/jni/onload.cpp b/native/jni/jni_common.cpp
similarity index 73%
rename from native/jni/onload.cpp
rename to native/jni/jni_common.cpp
index f02c9a052d18cd97a878a9575b18d8b0ab7b1030..8643f723f7cec0fb064e7ccb027177dd4beb2d67 100644
--- a/native/jni/onload.cpp
+++ b/native/jni/jni_common.cpp
@@ -26,11 +26,8 @@
 #include <errno.h>
 #include <stdio.h>
 
-// ----------------------------------------------------------------------------
-
 using namespace latinime;
 
-
 /*
  * Returns the JNI version on success, -1 on failure.
  */
@@ -60,3 +57,23 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
 bail:
     return result;
 }
+
+namespace latinime {
+
+int registerNativeMethods(JNIEnv* env, const char* className, JNINativeMethod* methods,
+        int numMethods) {
+    jclass clazz = env->FindClass(className);
+    if (clazz == NULL) {
+        LOGE("Native registration unable to find class '%s'", className);
+        return JNI_FALSE;
+    }
+    if (env->RegisterNatives(clazz, methods, numMethods) < 0) {
+        LOGE("RegisterNatives failed for '%s'", className);
+        env->DeleteLocalRef(clazz);
+        return JNI_FALSE;
+    }
+    env->DeleteLocalRef(clazz);
+    return JNI_TRUE;
+}
+
+} // namespace latinime
diff --git a/native/jni/jni_common.h b/native/jni/jni_common.h
new file mode 100644
index 0000000000000000000000000000000000000000..c502fa3a8c431f221b9667ea9d543754a8d64be8
--- /dev/null
+++ b/native/jni/jni_common.h
@@ -0,0 +1,30 @@
+/*
+**
+** Copyright 2011, 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_JNI_COMMON_H
+#define LATINIME_JNI_COMMON_H
+
+#include "jni.h"
+
+namespace latinime {
+
+int registerNativeMethods(JNIEnv* env, const char* className, JNINativeMethod* methods,
+        int numMethods);
+
+} // namespace latinime
+
+#endif // LATINIME_JNI_COMMON_H
diff --git a/native/src/bigram_dictionary.h b/native/src/bigram_dictionary.h
index d658b93e620068b2c16a036b20efb7d7b1ee946e..c07458a381de40d6b89b737416bd4e17dd4aa2c6 100644
--- a/native/src/bigram_dictionary.h
+++ b/native/src/bigram_dictionary.h
@@ -50,6 +50,7 @@ private:
     int *mInputCodes;
     int mInputLength;
 };
-// ----------------------------------------------------------------------------
-}; // namespace latinime
+
+} // namespace latinime
+
 #endif // LATINIME_BIGRAM_DICTIONARY_H
diff --git a/native/src/char_utils.h b/native/src/char_utils.h
index 921ecb4a57c913b4780ec8adacba7dd924b99a2a..a69a35e7a9bc86e0b078b1eef07ad4bfdcd14c1f 100644
--- a/native/src/char_utils.h
+++ b/native/src/char_utils.h
@@ -21,6 +21,6 @@ namespace latinime {
 
 unsigned short latin_tolower(unsigned short c);
 
-}; // namespace latinime
+} // namespace latinime
 
 #endif // LATINIME_CHAR_UTILS_H
diff --git a/native/src/debug.h b/native/src/debug.h
index ae629b22264a85c7314031b7f6b51c92dd253bfe..38b2f107a4260800b519cb05d31aad2d88928f19 100644
--- a/native/src/debug.h
+++ b/native/src/debug.h
@@ -28,6 +28,7 @@ static inline unsigned char* convertToUnibyteString(unsigned short* input, unsig
     output[i] = 0;
     return output;
 }
+
 static inline unsigned char* convertToUnibyteStringAndReplaceLastChar(unsigned short* input,
         unsigned char* output, const unsigned int length, unsigned char c) {
     int i = 0;
@@ -37,6 +38,7 @@ static inline unsigned char* convertToUnibyteStringAndReplaceLastChar(unsigned s
     output[i] = 0;
     return output;
 }
+
 static inline void LOGI_S16(unsigned short* string, const unsigned int length) {
     unsigned char tmp_buffer[length];
     convertToUnibyteString(string, tmp_buffer, length);
@@ -46,6 +48,7 @@ static inline void LOGI_S16(unsigned short* string, const unsigned int length) {
     // TODO : refactor this in a blocking log or something.
     // usleep(10);
 }
+
 static inline void LOGI_S16_PLUS(unsigned short* string, const unsigned int length,
         unsigned char c) {
     unsigned char tmp_buffer[length+1];
diff --git a/native/src/dictionary.h b/native/src/dictionary.h
index 1b41f69dde8a8455670df5e3ad3b181039eaff76..3dc577a56b1583aa4217d79dab3feca37269a126 100644
--- a/native/src/dictionary.h
+++ b/native/src/dictionary.h
@@ -81,7 +81,6 @@ private:
     BigramDictionary *mBigramDictionary;
 };
 
-// ----------------------------------------------------------------------------
 // public static utility methods
 // static inline methods should be defined in the header file
 inline unsigned short Dictionary::getChar(const unsigned char *dict, int *pos) {
@@ -134,7 +133,6 @@ inline int Dictionary::getFreq(const unsigned char *dict,
     return freq;
 }
 
-
 inline int Dictionary::wideStrLen(unsigned short *str) {
     if (!str) return 0;
     unsigned short *end = str;
@@ -158,5 +156,6 @@ inline int Dictionary::setDictionaryValues(const unsigned char *dict,
     return position;
 }
 
-}; // namespace latinime
+} // namespace latinime
+
 #endif // LATINIME_DICTIONARY_H
diff --git a/native/src/proximity_info.cpp b/native/src/proximity_info.cpp
index 102123c3ce024c6a6e8ebb761f04f28c17a47994..209c31e6e64254e79249852908edf86deab8a0ec 100644
--- a/native/src/proximity_info.cpp
+++ b/native/src/proximity_info.cpp
@@ -22,6 +22,7 @@
 #include "proximity_info.h"
 
 namespace latinime {
+
 ProximityInfo::ProximityInfo(const int maxProximityCharsSize, const int keyboardWidth,
         const int keyboardHeight, const int gridWidth, const int gridHeight,
         const uint32_t *proximityCharsArray)
@@ -61,4 +62,5 @@ bool ProximityInfo::hasSpaceProximity(const int x, const int y) const {
     }
     return false;
 }
-}  // namespace latinime
+
+} // namespace latinime
diff --git a/native/src/proximity_info.h b/native/src/proximity_info.h
index c2062e8c5a4a450bba50e4cf77deebbb09a0d73f..327cd0940f8bb7f6d7d8a62c1875754240554e76 100644
--- a/native/src/proximity_info.h
+++ b/native/src/proximity_info.h
@@ -41,5 +41,7 @@ private:
     const int CELL_HEIGHT;
     uint32_t *mProximityCharsArray;
 };
-}; // namespace latinime
+
+} // namespace latinime
+
 #endif // LATINIME_PROXIMITY_INFO_H
diff --git a/native/src/unigram_dictionary.h b/native/src/unigram_dictionary.h
index 3593dd65682a0f55c623bdd9d5c1bd046a3573bb..154ac9b36a45cf6377fa14d8b8f411e1ae9ab1a9 100644
--- a/native/src/unigram_dictionary.h
+++ b/native/src/unigram_dictionary.h
@@ -147,8 +147,6 @@ private:
     int mNextLettersFrequency[NEXT_LETTERS_SIZE];
 };
 
-// ----------------------------------------------------------------------------
-
-}; // namespace latinime
+} // namespace latinime
 
 #endif // LATINIME_UNIGRAM_DICTIONARY_H