More minor tweaks to JS to prevent NaN on dates