lots of JS fixes