switch to (hopefully) cross-platform nan checks.