Fixing assertion failure introduced in 196602.

Also includes a minor refactor with no functional change.