Fixes #1869

See issue descriptoin.