Some optimizations, especially js