Uses `prototype` for declaring member functions

We had a mixed way of using `ClassName.prototype.functionName = function() {}` and `this.functionName = function() {}` (from inside the constructor). Using the prototype way allows for browser optimization as it can compile the functions once instead of having to compile each time an object is initialized.