casts for c++ compatibility added