diff --git a/lib/js/thrift.js b/lib/js/thrift.js
index 5c1fdf1..b8ca2c0 100644
--- a/lib/js/thrift.js
+++ b/lib/js/thrift.js
@@ -54,13 +54,16 @@
 
     objectLength: function(obj) {
         var length = 0;
-        for (k in obj)
-            if (obj.hasOwnProperty(k))
+        for (var k in obj) {
+            if (obj.hasOwnProperty(k)) {
               length++;
+            }
+        }
+
         return length;
     },
 
-    inherits: function(constructor, superConstructor) {
+    inherits: function(constructor, superConstructor) {
       //Prototypal Inheritance http://javascript.crockford.com/prototypal.html
       function F() {}
       F.prototype = superConstructor.prototype;
@@ -73,7 +76,7 @@
 Thrift.TException.prototype = {
     initialize: function(message, code) {
             this.message = message;
-            this.code = (code == null) ? 0 : code;
+            this.code = (code === null) ? 0 : code;
     }
 };
 
@@ -89,17 +92,18 @@
 
 Thrift.TApplicationException = function(message, code) {
     this.message = message;
-    this.code = (code == null) ? 0 : code;
+    this.code = (code === null) ? 0 : code;
 };
 
 Thrift.TApplicationException.prototype = {
 
     read: function(input) {
         while (1) {
-            ret = input.readFieldBegin();
+            var ret = input.readFieldBegin();
 
-            if (ret.ftype == Thrift.Type.STOP)
+            if (ret.ftype == Thrift.Type.STOP) {
                 break;
+            }
 
             var fid = ret.fid;
 
@@ -183,9 +187,9 @@
     //Gets the browser specific XmlHttpRequest Object
     getXmlHttpRequestObject: function() {
 
-        try { return new XMLHttpRequest() } catch (e) {}
-        try { return new ActiveXObject('Msxml2.XMLHTTP') } catch (e) {}
-        try { return new ActiveXObject('Microsoft.XMLHTTP') } catch (e) {}
+        try { return new XMLHttpRequest(); } catch (e1) { }
+        try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch (e2) { }
+        try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch (e3) { }
 
         throw "Your browser doesn't support the XmlHttpRequest object.";
 
@@ -194,22 +198,26 @@
     flush: function() {
 
         //async mode
-        if (this.url == undefined || this.url == '')
+        if (this.url === undefined || this.url === '') {
             return this.send_buf;
+        }
 
         var xreq = this.getXmlHttpRequestObject();
 
-        if (xreq.overrideMimeType)
+        if (xreq.overrideMimeType) {
             xreq.overrideMimeType('application/json');
+        }
 
         xreq.open('POST', this.url, false);
         xreq.send(this.send_buf);
 
-        if (xreq.readyState != 4)
+        if (xreq.readyState != 4) {
             throw 'encountered an unknown ajax ready state: ' + xreq.readyState;
+        }
 
-        if (xreq.status != 200)
+        if (xreq.status != 200) {
             throw 'encountered a unknown request status: ' + xreq.status;
+        }
 
         this.recv_buf = xreq.responseText;
         this.recv_buf_sz = this.recv_buf.length;
@@ -235,13 +243,15 @@
     read: function(len) {
         var avail = this.wpos - this.rpos;
 
-        if (avail == 0)
+        if (avail === 0) {
             return '';
+        }
 
         var give = len;
 
-        if (avail < len)
+        if (avail < len) {
             give = avail;
+        }
 
         var ret = this.read_buf.substr(this.rpos, give);
         this.rpos += give;
@@ -251,7 +261,7 @@
     },
 
     readAll: function() {
-       return this.recv_buf;
+        return this.recv_buf;
     },
 
     write: function(buf) {
@@ -285,17 +295,17 @@
 
 
 Thrift.Protocol.RType = {};
-Thrift.Protocol.RType['tf'] = Thrift.Type.BOOL;
-Thrift.Protocol.RType['i8'] = Thrift.Type.BYTE;
-Thrift.Protocol.RType['i16'] = Thrift.Type.I16;
-Thrift.Protocol.RType['i32'] = Thrift.Type.I32;
-Thrift.Protocol.RType['i64'] = Thrift.Type.I64;
-Thrift.Protocol.RType['dbl'] = Thrift.Type.DOUBLE;
-Thrift.Protocol.RType['rec'] = Thrift.Type.STRUCT;
-Thrift.Protocol.RType['str'] = Thrift.Type.STRING;
-Thrift.Protocol.RType['map'] = Thrift.Type.MAP;
-Thrift.Protocol.RType['lst'] = Thrift.Type.LIST;
-Thrift.Protocol.RType['set'] = Thrift.Type.SET;
+Thrift.Protocol.RType.tf = Thrift.Type.BOOL;
+Thrift.Protocol.RType.i8 = Thrift.Type.BYTE;
+Thrift.Protocol.RType.i16 = Thrift.Type.I16;
+Thrift.Protocol.RType.i32 = Thrift.Type.I32;
+Thrift.Protocol.RType.i64 = Thrift.Type.I64;
+Thrift.Protocol.RType.dbl = Thrift.Type.DOUBLE;
+Thrift.Protocol.RType.rec = Thrift.Type.STRUCT;
+Thrift.Protocol.RType.str = Thrift.Type.STRING;
+Thrift.Protocol.RType.map = Thrift.Type.MAP;
+Thrift.Protocol.RType.lst = Thrift.Type.LIST;
+Thrift.Protocol.RType.set = Thrift.Type.SET;
 
 Thrift.Protocol.Version = 1;
 
@@ -307,10 +317,10 @@
 
     //Write functions
     writeMessageBegin: function(name, messageType, seqid) {
-        this.tstack = new Array();
-        this.tpos = new Array();
-
-        this.tstack.push([Thrift.Protocol.Version, '"' +
+        this.tstack = [];
+        this.tpos = [];
+
+        this.tstack.push([Thrift.Protocol.Version, '"' +
             name + '"', messageType, seqid]);
     },
 
@@ -338,10 +348,11 @@
         var str = '{';
         var first = true;
         for (var key in struct) {
-            if (first)
+            if (first) {
                 first = false;
-            else
+            } else {
                 str += ',';
+            }
 
             str += key + ':' + struct[key];
         }
@@ -351,18 +362,18 @@
     },
 
     writeFieldBegin: function(name, fieldType, fieldId) {
-        this.tpos.push(this.tstack.length);
-        this.tstack.push({ 'fieldId': '"' +
-            fieldId + '"', 'fieldType': Thrift.Protocol.Type[fieldType]
+        this.tpos.push(this.tstack.length);
+        this.tstack.push({ 'fieldId': '"' +
+            fieldId + '"', 'fieldType': Thrift.Protocol.Type[fieldType]
         });
 
     },
 
     writeFieldEnd: function() {
         var value = this.tstack.pop();
-        var fieldInfo = this.tstack.pop();
-
-        this.tstack[this.tstack.length - 1][fieldInfo.fieldId] = '{' +
+        var fieldInfo = this.tstack.pop();
+
+        this.tstack[this.tstack.length - 1][fieldInfo.fieldId] = '{' +
             fieldInfo.fieldType + ':' + value + '}';
         this.tpos.pop();
     },
@@ -373,7 +384,7 @@
 
     writeMapBegin: function(keyType, valType, size) {
         //size is invalid, we'll set it on end.
-        this.tpos.push(this.tstack.length);
+        this.tpos.push(this.tstack.length);
         this.tstack.push([Thrift.Protocol.Type[keyType],
             Thrift.Protocol.Type[valType], 0]);
     },
@@ -381,11 +392,13 @@
     writeMapEnd: function() {
         var p = this.tpos.pop();
 
-        if (p == this.tstack.length)
+        if (p == this.tstack.length) {
             return;
+        }
 
-        if ((this.tstack.length - p - 1) % 2 != 0)
+        if ((this.tstack.length - p - 1) % 2 !== 0) {
             this.tstack.push('');
+        }
 
         var size = (this.tstack.length - p - 1) / 2;
 
@@ -398,7 +411,7 @@
             var k = this.tstack.pop();
             if (first) {
                 first = false;
-            }else {
+            } else {
                 map = ',' + map;
             }
 
@@ -515,8 +528,8 @@
 
     // Reading functions
     readMessageBegin: function(name, messageType, seqid) {
-        this.rstack = new Array();
-        this.rpos = new Array();
+        this.rstack = [];
+        this.rpos = [];
 
         this.robj = eval(this.transport.readAll());
 
@@ -527,9 +540,9 @@
             throw 'Wrong thrift protocol version: ' + version;
         }
 
-        r['fname'] = this.robj.shift();
-        r['mtype'] = this.robj.shift();
-        r['rseqid'] = this.robj.shift();
+        r.fname = this.robj.shift();
+        r.mtype = this.robj.shift();
+        r.rseqid = this.robj.shift();
 
 
         //get to the main obj
@@ -544,18 +557,20 @@
 
     readStructBegin: function(name) {
         var r = {};
-        r['fname'] = '';
+        r.fname = '';
 
         //incase this is an array of structs
-        if (this.rstack[this.rstack.length - 1] instanceof Array)
+        if (this.rstack[this.rstack.length - 1] instanceof Array) {
             this.rstack.push(this.rstack[this.rstack.length - 1].shift());
+        }
 
         return r;
     },
 
     readStructEnd: function() {
-        if (this.rstack[this.rstack.length - 2] instanceof Array)
+        if (this.rstack[this.rstack.length - 2] instanceof Array) {
             this.rstack.pop();
+        }
     },
 
     readFieldBegin: function() {
@@ -566,12 +581,14 @@
 
         //get a fieldId
         for (var f in (this.rstack[this.rstack.length - 1])) {
-            if (f == null) continue;
+            if (f === null) {
+              continue;
+            }
 
-            fid = parseInt(f);
+            fid = parseInt(f, 10);
             this.rpos.push(this.rstack.length);
 
-            var field = this.rstack[this.rstack.length - 1][fid]
+            var field = this.rstack[this.rstack.length - 1][fid];
 
             //remove so we don't see it again
             delete this.rstack[this.rstack.length - 1][fid];
@@ -585,18 +602,20 @@
 
             //should only be 1 of these but this is the only
             //way to match a key
-            for (var f in (this.rstack[this.rstack.length - 1])) {
-                if (Thrift.Protocol.RType[f] == null) continue;
+            for (var i in (this.rstack[this.rstack.length - 1])) {
+                if (Thrift.Protocol.RType[i] === null) {
+                    continue;
+                }
 
-                ftype = Thrift.Protocol.RType[f];
+                ftype = Thrift.Protocol.RType[i];
                 this.rstack[this.rstack.length - 1] =
-                    this.rstack[this.rstack.length - 1][f];
+                    this.rstack[this.rstack.length - 1][i];
             }
         }
 
-        r['fname'] = '';
-        r['ftype'] = ftype;
-        r['fid'] = fid;
+        r.fname = '';
+        r.ftype = ftype;
+        r.fid = fid;
 
 
         return r;
@@ -606,8 +625,9 @@
         var pos = this.rpos.pop();
 
         //get back to the right place in the stack
-        while (this.rstack.length > pos)
+        while (this.rstack.length > pos) {
             this.rstack.pop();
+        }
 
     },
 
@@ -616,9 +636,9 @@
         var map = this.rstack.pop();
 
         var r = {};
-        r['ktype'] = Thrift.Protocol.RType[map.shift()];
-        r['vtype'] = Thrift.Protocol.RType[map.shift()];
-        r['size'] = map.shift();
+        r.ktype = Thrift.Protocol.RType[map.shift()];
+        r.vtype = Thrift.Protocol.RType[map.shift()];
+        r.size = map.shift();
 
 
         this.rpos.push(this.rstack.length);
@@ -636,8 +656,8 @@
         var list = this.rstack[this.rstack.length - 1];
 
         var r = {};
-        r['etype'] = Thrift.Protocol.RType[list.shift()];
-        r['size'] = list.shift();
+        r.etype = Thrift.Protocol.RType[list.shift()];
+        r.size = list.shift();
 
 
         this.rpos.push(this.rstack.length);
@@ -661,10 +681,10 @@
     readBool: function() {
         var r = this.readI32();
 
-        if (r != null && r['value'] == '1') {
-            r['value'] = true;
-        }else {
-            r['value'] = false;
+        if (r !== null && r.value == '1') {
+            r.value = true;
+        } else {
+            r.value = false;
         }
 
         return r;
@@ -680,28 +700,31 @@
 
 
     readI32: function(f) {
-        if (f == undefined)
+        if (f === undefined) {
             f = this.rstack[this.rstack.length - 1];
+        }
 
         var r = {};
 
         if (f instanceof Array) {
-            if (f.length == 0)
-                r['value'] = undefined;
-            else
-                r['value'] = f.shift();
-
-        }else if (f instanceof Object) {
+            if (f.length === 0) {
+                r.value = undefined;
+            } else {
+                r.value = f.shift();
+            }
+        } else if (f instanceof Object) {
            for (var i in f) {
-                if (i == null) continue;
-                this.rstack.push(f[i])
+                if (i === null) {
+                  continue;
+                }
+                this.rstack.push(f[i]);
                 delete f[i];
 
-                r['value'] = i;
+                r.value = i;
                 break;
            }
         } else {
-            r['value'] = f;
+            r.value = f;
             this.rstack.pop();
         }
 
