Tidy-up code.

C++y casts