Fixed stuff JSLint/JSHint complained about

and some formatting