Applied bugfix from pull-request #313