Small Javascript optimizations