more constification and static_cast changes

* constify things that should be const
* change some c-style casts (those in assignment statements) to c++
  static_casts. This helps to see where const qualifiers were being cast
  away
* fix the resulting breakages