Defined Quad function.
Fixed a number of error that jslint caught.