Backport Nokogiri fixes into AF5