Closes #3595 Based on patch by Tristan Lelong <tristan.lelong@blunderer.org>. Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>