some rework to fix jslint issues.