(imported from commit 4270f31fc5febcd9c444d0d133a1dad3860618f0)
Fixes #482. (imported from commit 1bd6a7fd993d8d5e225e0311c288dbce0c369a40)