Fixes issue #1652.
Fixes issue #1287.