diff --git a/routerjars/jni/build.sh b/routerjars/jni/build.sh
index d7e0d05a3fe6bd065ecf4669eba06d75e92ddb89..81b87f2f127c4fced4e1d7a70b7af4e4b5f4c0ef 100755
--- a/routerjars/jni/build.sh
+++ b/routerjars/jni/build.sh
@@ -15,8 +15,12 @@
 #
 #THISDIR=$(realpath $(dirname $(which $0)))
 
-## Making it work on osx too.
-THISDIR=$(dirname $(readlink -ne $0))
+## works on linux and other unixes, but not osx.
+if [ "`uname -s`" != "Darwin" ]; then
+    THISDIR=$(dirname $(readlink -ne $0))
+else
+    THISDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+fi
 cd $THISDIR
 
 LIBFILE=$PWD/libjbigi.so
@@ -49,7 +53,11 @@ LEVEL=8
 ARCH=arm
 export SYSROOT=$NDK/platforms/android-$LEVEL/arch-$ARCH/
 export AABI=arm-linux-androideabi-4.4.3
-export SYSTEM=linux-x86
+if [ "`uname -s`" == "Darwin" ]; then
+    export SYSTEM=darwin-x86
+else
+    export SYSTEM=linux-x86
+fi
 export BINPREFIX=arm-linux-androideabi-
 export CC="$NDK/toolchains/$AABI/prebuilt/$SYSTEM/bin/${BINPREFIX}gcc --sysroot=$SYSROOT"
 # worked without this on 4.3.2, but 5.0.2 couldn't find it
@@ -88,14 +96,20 @@ cd build
 if [ ! -f config.status ]
 then
 	echo "Configuring GMP..."
-	$GMP/configure --with-pic --build=x86-none-linux --host=armv5-eabi-linux || exit 1
+    if [ "`uname -s`" == "Darwin" ]; then
+	    $GMP/configure --with-pic --build=x86-darwin --host=armv5-eabi-linux || exit 1
+    else
+	    $GMP/configure --with-pic --build=x86-none-linux --host=armv5-eabi-linux || exit 1
+    fi
 fi
 
 echo "Building GMP..."
 make || exit 1
 
 if [ "`uname -s`" == "Darwin" ]; then
-    export JAVA_HOME="/Library/Java/Home"
+    # Depends on version
+    # TODO: Fix something for finding the newest jdk and set it as home.
+    export JAVA_HOME="/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/"
 else
     export JAVA_HOME=$(dirname $(dirname $(realpath $(which javac))))
 fi
diff --git a/src/net/i2p/android/router/activity/AddressbookSettingsActivity.java b/src/net/i2p/android/router/activity/AddressbookSettingsActivity.java
index 2cb4f264cfe2cee070b42cfe89d807b0c384ef45..cfae14b83cad568638ab17fbf1f2fef01ec8dea9 100644
--- a/src/net/i2p/android/router/activity/AddressbookSettingsActivity.java
+++ b/src/net/i2p/android/router/activity/AddressbookSettingsActivity.java
@@ -1,18 +1,15 @@
 package net.i2p.android.router.activity;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
+import java.io.IOException;
 
+import net.i2p.util.FileUtil;
 
 import net.i2p.android.router.R;
 import android.os.Bundle;
 import android.app.Activity;
 import android.content.Context;
-import android.util.Log;
 import android.view.Menu;
 import android.view.View;
 import android.widget.Button;
@@ -21,11 +18,11 @@ import android.widget.Toast;
 
 public class AddressbookSettingsActivity extends Activity {
 
-	protected EditText text_content_subscriptions;
+    protected EditText text_content_subscriptions;
     protected Button btn_save_subscriptions;
     private String filename = "/addressbook/subscriptions.txt";
-    private String i2pDir;
-	
+    private File i2pDir;
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -33,7 +30,7 @@ public class AddressbookSettingsActivity extends Activity {
         text_content_subscriptions = (EditText) findViewById(R.id.subscriptions_content);
         btn_save_subscriptions = (Button) findViewById(R.id.button_save_subscriptions);
         init_actions();
-        i2pDir = getFilesDir().getAbsolutePath();
+        i2pDir = new File(getFilesDir(), filename);
         load();
     }
 
@@ -42,61 +39,49 @@ public class AddressbookSettingsActivity extends Activity {
         getMenuInflater().inflate(R.menu.activity_addressbook_settings, menu);
         return true;
     }
-    
+
     private void init_actions() {
-    	btn_save_subscriptions.setOnClickListener(new View.OnClickListener() {
+        btn_save_subscriptions.setOnClickListener(new View.OnClickListener() {
             public void onClick(View view) {
-            	Context context = getApplicationContext();
-            	CharSequence text = "";
-            	if (save()) {
-            		text = "subscriptions.txt successfully saved!";
-            	} else {
-            		text = "there was a problem saving subscriptions.txt! Try fix permissions or reinstall i2p.";
-            	}
-            	Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
+                Context context = getApplicationContext();
+                CharSequence text = "";
+                if (save()) {
+                    text = "subscriptions.txt successfully saved!";
+                } else {
+                    text = "there was a problem saving subscriptions.txt! Try fix permissions or reinstall i2p.";
+                }
+                Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
             }
         });
     }
-    
+
     private boolean load() {
-    	String res = null;
-    	FileInputStream in;
-		try {
-			in = new FileInputStream(new File(i2pDir+filename));
-			if (in != null) {
-	    		InputStreamReader input = new InputStreamReader(in);
-	    		BufferedReader buffreader = new BufferedReader(input);
-	    		res="";
-	    		String line = null;
-	    		while (( line = buffreader.readLine()) != null) {
-	    			res += line+"\n";
-	    		}
-	    		in.close();
-	    		text_content_subscriptions.setText(res);
-	    		return true;
-			}
-		} catch (Exception e) {
-			Log.e("I2P-AddressbookSettings", "Can't read subscriptions.txt");
-			//TODO: Add error reporting support
-			e.printStackTrace();
-			return false;
-		}
-		return false;
+        String res = FileUtil.readTextFile(i2pDir.getAbsolutePath(), -1, true);
+        if (res.length() > 0) {
+            text_content_subscriptions.setText(res);
+            return true;
+        }
+        Context context = getApplicationContext();
+        CharSequence text = "Sorry, could not load subscriptions.txt!";
+        Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
+        return false;
     }
-    
+
     private boolean save() {
-    	//
-    	String content = text_content_subscriptions.getText().toString();
-    	try {
-    		FileOutputStream out = new FileOutputStream(new File(i2pDir+filename));
-			byte[] contentInBytes = content.getBytes();
-    		out.write(contentInBytes);
-			out.flush();
-			out.close();
-			return true;
-		} catch (Exception e) {
-			e.printStackTrace();
-			return false;
-		}
+        //
+        String content = text_content_subscriptions.getText().toString();
+        FileOutputStream out = null;
+        try {
+            out = new FileOutputStream(i2pDir);
+            byte[] contentInBytes = content.getBytes();
+            out.write(contentInBytes);
+            out.close();
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        } finally {
+        	if (out != null) try {out.close(); } catch (IOException ioe) {}
+        }
     }
 }