Fixes #1515, enhances #1849

Fixes #1515, enhances #1849.