Applied Thorsten-Sick pull request #117 and #106