Performance and readability oriented changes.

I didn't end up gaining anything notable in terms of performance,
but I simplified some stuff a little in the process.