Added cast for c++ friendliness