Minor JS re-factoring.