Fix gcc warnings about casting away constness