Added a few casts to make C++ happy.