Fix part of PR12457. Patch by Justin Bogner!