fixed as much JSLint silly complains as possible but not more than that