Use local vars to improve readability. No functional change.

Completes what was started in r216611 and r216623.
Used const refs instead of pointers; not sure if one is preferable to the other.