Fix to match upstream

Mimic part of patch 1c9ccc6 by eviltrout