First work on issue #508
Merge pull request #519 from pvankouteren/issue-508-again

First work on issue #508