More fixes from last upstream merge.