Get rid of JSLint errors and performance problem