Updated code according to some JSLint issues