Make the scanner faster.

Move lots of cases that are almost never hit to a helper method.  Don't depend on NaNs to know
when we're at the end of an array.  It causes V8 to unoptimize our functions.