Optimization tweaks.

Less readable, but faster!