Changes to handle NaN better. Also move the function execution to its own executor file with its own scope.