Some js optimizations