Minor JS bug fixes