Added some JS optimizations