add casts where necessary for warning avoidance