Corrected some mistakes according to hints from JsHint