Performance improvements to vectorization and number operations

Optimize local hotspots, such a more direct path for numeric comparison
and reordering to avoid NaN checks.