JS hint and code cleanup