JS fixes and improvements