Backported fixes.