Changing checks for NaN so they work in Safari. Closes #170.