Make code pass lint

I've touched up all the JavaScript files so they would pass a lint, and so they wouldn't throw error if you ran them in strict mode. I've also done a tiny bit of optimizing of some of the small functions that could be cut down to a single return statement instead of a small if block. I may go through and do cpu/memory optimizations later.