Added casts to eliminate compiler warnings.