Minor JS code improvements