Silencing some -Wcast-qual warnings and removing some C-style casts at the same time. NFC.