Fix nan/inf checks

Note to self: nan != nan