js style and code cleanup