Cherry picked fixes for 5.2