Added a few casts to throw away const