diff --git a/index.js b/index.js
index bd00367eec56cdeef5f1119253fa392c28d6b449..d2aa61814974c7a9138ca0ba9f3b267e4bbaec00 100644
--- a/index.js
+++ b/index.js
@@ -32,8 +32,9 @@ var balance = web3.eth.getBalance(coinbase);
 console.log(balance.toString(10));
 
 var REG_ADDR_FILE = "contractAddress.txt";
-var REG_ADDR = "0x1b364554e859d3277d3477ef6bf21113464e2392";
-var REG_ABI = [{"constant":true,"inputs":[{"name":"_a","type":"address"}],"name":"name","outputs":[{"name":"o_name","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"content","outputs":[{"name":"","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"addr","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserve","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"subRegistrar","outputs":[{"name":"o_subRegistrar","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_owner","type":"address"},{"name":"_a","type":"address"}],"name":"reserveFor","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"transfer","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_registrar","type":"address"}],"name":"setSubRegistrar","outputs":[],"type":"function"},{"constant":false,"inputs":[],"name":"Registrar","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_a","type":"address"},{"name":"_primary","type":"bool"}],"name":"setAddress","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_content","type":"bytes32"}],"name":"setContent","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"disown","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"register","outputs":[{"name":"","type":"address"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"}],"name":"Changed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"addr","type":"address"},{"indexed":false,"name":"owner","type":"address"}],"name":"PrimaryChanged","type":"event"}];
+var REG_ABI_FILE = "contractABI.json";
+var REG_ADDR = "0xe53cb2ace8707526a5050bec7bcf979c57f8b44f";
+var REG_ABI = [{"constant":true,"inputs":[{"name":"_a","type":"address"}],"name":"name","outputs":[{"name":"o_name","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"content","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"addr","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"subRegistrar","outputs":[{"name":"o_subRegistrar","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_a","type":"address"}],"name":"reserve","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_owner","type":"address"},{"name":"_a","type":"address"}],"name":"reserveFor","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"transfer","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_registrar","type":"address"}],"name":"setSubRegistrar","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"Registrar","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_a","type":"address"},{"name":"_primary","type":"bool"}],"name":"setAddress","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_content","type":"bytes32"}],"name":"setContent","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"disown","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"register","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"}],"name":"Changed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"addr","type":"address"},{"indexed":false,"name":"owner","type":"address"}],"name":"PrimaryChanged","type":"event"}];
 
 var account;
 var regContract;
@@ -69,30 +70,39 @@ function waitForGaz(want, cb) {
 
 function loadContract() {
     fs.readFile(REG_ADDR_FILE, function(err, content) {
-        if (!err) {
-            REG_ADDR = content;
-        } else {
+        if (err) {
             console.log("Can't read contract address: " + err);
+        } else {
+            REG_ADDR = String(content);
         }
-        console.log("Loading name contract from blockchain at " + REG_ADDR);
-        web3.eth.getCode(REG_ADDR, function(error, result) {
-            //console.log("Contract code at " + REG_ADDR + ": " + result);
-            if (result == "0x") {
-                console.log("Contract not found at " + REG_ADDR);
-                initContract();
-            } else {
-                regContract = web3.eth.contract(REG_ABI);
-                regContract.at(REG_ADDR, function(err, result) {
-                    console.log("Contract found and loaded from " + REG_ADDR);
-                    if(!err) {
-                        reg = result;
-                        startServer();
-                    }
-                    else {
-                        console.error("err: " + err);
-                    }
-                });
-            }
+        fs.readFile(REG_ABI_FILE, function(err, abi_str){
+            if (err)
+                console.log("Can't read contract ABI: " + err);
+            else
+                REG_ABI = JSON.parse(abi_str);
+            console.log("Loading name contract from blockchain at " + REG_ADDR);
+            web3.eth.getCode(REG_ADDR, function(error, result) {
+                if (error)
+                    console.log("Error getting contract code: " + error);
+                /*else
+                    console.log("Contract code at " + REG_ADDR + ": " + result);*/
+                if (!result || result == "0x") {
+                    console.log("Contract not found at " + REG_ADDR);
+                    initContract();
+                } else {
+                    regContract = web3.eth.contract(REG_ABI);
+                    regContract.at(REG_ADDR, function(err, result) {
+                        console.log("Contract found and loaded from " + REG_ADDR);
+                        if(!err) {
+                            reg = result;
+                            startServer();
+                        }
+                        else {
+                            console.error("err: " + err);
+                        }
+                    });
+                }
+            });
         });
     });
 }
@@ -108,6 +118,7 @@ function initContract() {
             }
             console.log("Contract compiled, instantiating on blockchain...");
             REG_ABI = compiled.GlobalRegistrar.info.abiDefinition;
+            fs.writeFile(REG_ABI_FILE, JSON.stringify(REG_ABI));
             regContract = web3.eth.contract(REG_ABI);
             waitForGaz(3000000, function(){
                 regContract.new({from: coinbase, data: compiled.GlobalRegistrar.code, gas: 3000000}, function(e, contract){