Stylistc corrections, change n_build function def

N_build can be a toplevel declaration, instead just taking in "newtext"
as an argument.

Minor stylistic corrections (js-beautify), semicolons, etc.