Manually add change from pull/433

I accidentally merged the wrong pull request. This backs out pull/431
and replaces it with the change from pull/433