Remove a couple of useless casts in core headers

This helps users who compile their code with -Wuseless-cast.
Merge pull request #2915 from SpecLad:core-useless-casts