Merge "Fixed incorrect casts that broke rate control in some situations."