a few js optimizations