Reduce compiler warnings by adding appropriate casts.