JSlint-checked and optimized