Fixes from bay upstream for hydro rewrite