Fix warning about casting away const in some instances