Clean up some particularly ugly casting.

No functionality change.