fix JSLint errors, mostly the forward ref to functions